casting/truncating float to int??

MIB's icon

Now this is probably really obvious and in C I could do it easily with a cast,

(int)floatNumber

but how do I do this in javascript??

Thanks

MIB's icon

I just found the following:

x = (a/b) |0;

is that the best way of doing this??

Emmanuel Jourdan's icon

Math.floor() is probably what you're looking for.

MIB's icon

that's exactly what I was looking for. thanks