In my script i am making a difference between two différents values, but the problem is that there are a lot of decimals and this is what ruins my script, so if someone knows a possible way of rounding Numbers i would appreciate it.
You can call math.floor()
to round a number towards negative infinity, or math.ceil()
to round a number towards positive infinity. Try calling math.floor()
on the number + 0.5 if you'd like to round 0.1-0.5 towards negative infinity, and 0.6-0.9 towards positive infinity (though this won't work as expected with numbers bigger than 2^53 - 1).
This is what you do.
local Number = 5.7 print(math.ceil(Number)) -- prints 6 print(math.floor(Number)) -- prints 5