So I've looked everywhere for a good way to round. I've tried using math.floor and math.ceil, But I can never make it round to the nearest hundredth. Can anyone help?
This isn't too hard. There might be a better way, but as an example, you can use math.floor
. This rounds to the nearest whole number:
--// Nearest Whole Number local function round(num) return math.floor(num+0.5) end
You can change this to round to tenths:
--// Nearest Tenth local function round(num) return math.floor(((num*10)+0.5))/10 end
And so on:
--// Nearest Hundredth local function round(num) return math.floor(((num*100)+0.5))/100 end