[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: better float2str() C code, anyone?
- From: Asko Kauppi <asko.kauppi@...>
- Date: Wed, 1 Dec 2004 23:37:39 +0200
Hmm.. could the behaviour be checked at runtime, and altered?
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:
Users complaint that this is an error in Lua! And it does not help to
them to docs like http://lua-users.org/wiki/FloatingPoint ...
Can you imagine a document that it would be helpful to point your
users at? If you can, then perhaps we can write it.
As I see it Lua used to do The Right Thing. It used to use %.17g
which would give reliable external and internal conversion. As long
as the C library was "good enough". glibc and FreeBSD libc were good
enough, but many others weren't. It's a shame that Lua now masks poor
quality C implementations at the expense of reliability. It's not
particularly a shame that you changed it, it's a shame that the state
of C libraries meant you felt compelled to change it.