There aren’t any functions for performing this operation. How can I do it?
Modulo will work for this.
local function truncateToHundredths(x)
return x-x%0.01
end
x%0.01 will get the difference between x and it truncated to the hundredths place.
Then that value is subtracted from x to get the correct value.
16 Likes
Alternate solution:
math.floor((x*100)+0.5)/100
This method will also round it.
11 Likes