It's a pretty simple question that doesn't require much explanation but this problem I'm having is annoying. So how do you change a decimal number like 123.343 and round it to the nearest whole number? I'm not the best at math. Any help?
An elegant solution would be to add 0.5 and round it down.
function round(n) return math.floor(n + 0.5) end
There are several ways of rounding negative numbers. See this page for some more info. This implementation rounds -1.5 to -1, not -2.