I found myself wanting to round to numbers of greater accuracy than whole numbers (4.325 rounding to 4.33 instead of 4) so I wrote a pair of functions to do that!
function roundUp(number, places)
return math.ceil(number * math.pow(10,places)) / math.pow(10,places)
end
function roundDown(number, places)
return math.floor(number * math.pow(10,places)) / math.pow(10,places)
end
Not sure if there's a way to make these faster using something other than math.pow, but I couldn't think of an easy way to code it. Enjoy!
Personally, if I want a number rounded and printed, I use string.format("%0.2f",number) to get it nicely rounded to two decimals. That can't do round up/down though, I think.