Another try :-) -- unbiased rounding function round (x) if math.floor(x) == x then return x else return math.floor((x % 2.0 == 0.5) and x or x + 0.5) end end