lua-users home
lua-l archive

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



On Dec 01, 2004, at 21:37, Asko Kauppi wrote:


Hmm.. could the behaviour be checked at runtime, and altered?

Not easily no.

Though one could check a few commonly bad cases. I see an opportunity for the autoconf crowd.

Cheers,
 drj


1.12.2004 kello 23:25, David Jones kirjoitti:


On Dec 01, 2004, at 14:54, Luiz Henrique de Figueiredo wrote:

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 ...