Help with values rounding

image
I need good formula of math.round that can support a values like 15.2 or 20.2 but not a 15.0000000000002 ;

currently i use:


image

You’re on the right track, but instead of convertting the value to a negative, divide it. and instead of using a function like math.round, use math.floor to properly represent the decimal.

local d = 10^(decimalPlace or 0);
return math.floor(number*d)/d;

Not something you can avoid, as thats a precision issue in Lua.

1 Like

Oh, it worked! Tysm! Have a good day / night.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.