lua-users home
lua-l archive

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


> Using "math.floor(z)" instead of "z|0" will avoid raising an error:

> Unfortunately, this method (add 0x1p+52 and subtract 0x1p+52) gives wrong result for some inputs.

These things are connected.  I gave the simplest solution that gives an integer result where possible and errors out otherwise.  If you want something that works for all inputs you have to filter the values, specifically for NaN and any values larger than 0x1p+52 or less than -0x1p+52 (including +/-Inf) I would return verbatim.  This isn't an issue for me because I only want rounding when I want to store a value in an integer.