lua-users home
lua-l archive

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


On Sun, Jul 31, 2016 at 12:21 PM, Duane Leslie <parakleta@darkreality.org> wrote:
apparently it depends on your compiler version and switches.

Probably, we have to roll back to more robust solution.
Possible candidate:

function math.round(x)
   local two52 = 4503599627370496.0
   if x > -two52 and x < two52 then
      local y = math.floor(x + 0.5)
      return y - x == 0.5 and y - y%2 or y
   else
      return math.floor(x)
   end
end