lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Shmuel Zeigerman wrote:

David Given wrote:


I don't believe there's an easy way of doing 'ordinary' rounding; that is, 1.2 -> 1, 1.8 -> 2. In C, this is rint().


num >= 0 and math.floor(num+0.5) or math.floor(num-0.5)


Sorry, the right answer is:
    math.floor(num+0.5)

--
Shmuel