lua-users home
lua-l archive

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


> One issue I've had from time to time is that the default
>    #define LUA_NUMBER_FMT        "%.14g"
> is not long enough to do reversible conversions on doubles. I believe
> you need %.19g for the conversion to be reversible.

I think it's %.17g for IEEE doubles. (Despite what DBL_DIG says!)
Lua was like that once, but then you get ugly things like this:

> =string.format("%.17g",0.34)
0.34000000000000002

> =0.34
0.34

> =34/100
0.34

Users complaint that this is an error in Lua! And it does not help to point
them to docs like http://lua-users.org/wiki/FloatingPoint ...

--lhf