lua-users home
lua-l archive

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


On Sat, Jul 30, 2016 at 11:00 AM, Duane Leslie <parakleta@darkreality.org> wrote:
I gave the simplest solution that gives an integer result where possible and errors out otherwise. 
 
Unfortunately, "simplest solution" you gave is not a solution at all.
It gives wrong results even for integers stored as float:

> x=13510798882111490.0
> x|0
13510798882111490
> (x + 0x1p+52 - 0x1p+52)|0
13510798882111488

 
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.

Yes, this filter MUST be applied.


Anyway, your idea about x+2^52-2^52 is great!