Author Topic: Rounding  (Read 461 times)

I am making something for my RPG that makes it so you need lumber to build, but the problem is that I use a system that detects a brick's size and calculates the wood needed equivalent, then divides it to get the amount of wood needed. Most of the values are in the decimal point area, so how would I make it round it to remove the decimals.

mFloor(%num + 0.5); rounds up


-snip-
-unsnip-
mFloor(%num + 0.5); rounds up
That'll actually round correctly, not up.

1.3 + 0.5 = 1.8 rounded down will be 1.
1.5 + 0.5 = 2.0 rounded down will be 2.
1.6 + 0.5 = 2.1 rounded down will be 2.
« Last Edit: April 07, 2010, 11:38:19 PM by Triple Nickels »

or use mFloatLength(%num,0); - first arg is the number, second is the number of decimal places, and it rounds the last place correctly.