Game Development Community

Convert float to int

by Mark Brown · in Torque Game Engine · 10/27/2006 (4:41 pm) · 2 replies

I have spent the past 2 hours trying to convert a flaot to an int in a .cs script.
What am I missing.

Assume %diff_x to be either float or int.

In any other language, you would usually cast it:
%jx = (int)( %diff_x / 16 );

or more directly:
%jx = int( %diff_x / 16 );

The result should be signed integer.

#1
10/27/2006 (4:46 pm)
Survey says

here good ole search
#2
10/27/2006 (6:44 pm)
You have saved me another two hours.

Works fine except has the answers reversed


mFloor rounds down
mCeil rounds up

ie. mFloor(3.2) = 4
mCeil(3.7) = 3


Should be:
mFloor rounds down
mCeil rounds up

ie. mFloor(3.2) = 3
mCeil(3.7) = 4

Many many thanks