Game Development Community

Obtaining the whole part of a number

by Tim Saunders · in Torque Game Builder · 11/26/2007 (5:31 am) · 4 replies

How do I get the whole part of a number and ignore the decimal places in Torque script? I've checked through the documentation, but no joy so far.

#1
11/26/2007 (6:35 am)
Well I figured out a way of doing it:

%Number = mFloatLength(%Number, 0);

This reduces the number of decimal places in a float to zero.
#2
11/26/2007 (7:34 am)
Try

mFloor() or mCeil()

mFloor always rounds down (x>=1 x<2) = 1
mCeil always rounds up (x>1 x<=2) = 2

and for negatives

mFloor (x<=-1 x>-2) = -1
mCeiling (x<-1 x>=-2) = -2

Gabriel
#3
11/26/2007 (7:52 am)
Hey thanks that's exactly what I was after.
#4
11/28/2007 (5:00 am)
Tim,
You can also use mRound(%value). There are some other great general math functions listed in the HTML docs under Reference/General Math.