Game Development Community

Easy Math Question - Rounding and Decimals

by Nicolai Dutka · in Torque Game Engine · 10/13/2007 (2:58 pm) · 3 replies

I just want this to ALWAYS return a whole integer:

( 1 + (%rand1 / 100) ) * 180;

Right now, all I get is decimals because of the percentage multiplier.

#1
10/13/2007 (3:07 pm)
Use mFloor or mCeil to round a number.
#2
10/13/2007 (5:26 pm)
Uhm, why down or up enforced... what about math rounding. Aint it 'even' or something ?
#3
10/13/2007 (5:58 pm)
This makes it round properly. Note the '+0.5':

mFloor( ( 1 + (%rand1 / 100) ) * 180 +0.5);