Type Casting string to int

Hey there,

Can anyone verify if the following is a good practice for type casting:

var myString : String = "12345.35";
var myInt : int;

function Start()
{
    myInt = parseInt(myString);
}

Is there a better way? Does anyone know if this function rounds down or up?

I don’t know whether or not it will throw an exception due to the decimal point, or the rounding behaviour. I know in C# when you cast a float to an integer, it just chops off the decimal component (so 2.9999 casted would become 2).

My suggestion is to simply write some simple test case code and see what happens.

EDIT: also note that this isn’t actually type casting, just parsing to create the number.

Thanks for the reply.