Game Development Community

Round a number?

by Daniel Brown · in Torque Game Engine · 08/13/2005 (4:36 am) · 2 replies

Hey all,

How do I round a number to the nearest whole number in script? I can't find a function for it!!

Thanks

#1
08/13/2005 (5:14 am)
There are two functions:

mFloor() and mCeil(), depending on whether you wish to round down or up respectively. For other maths functions in script, look in mConsoleFunctions.cc
#2
08/13/2005 (9:34 am)
As Michael has pointed out you can use floor and ceil to round down or up. You can also round off using

%newval = mFloor(%val+0.5);