[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: lujit - Malformed number
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Sat, 4 Sep 2010 17:28:03 -0300
> There is dtoa for this purpose, see: <http://www.netlib.org/fp/>
> It's quite portable.
And about a quarter of the size of the whole Lua source; it translates
to about 30k of code. Plus dtoa is probably already part of libc; see
http://lua-users.org/lists/lua-l/2002-08/msg00193.html
> What I would like to see is that n = tonumber(tostring(n)) holds for
> all finite numbers, and that tostring(n) returns the shortest possible
> representation such that n = tonumber(tostring(n)) holds.
The price for this is ugly-looking strings ending with a row of nines
or with a row of zeros followed by what looks like noise. This upsets
(naive) users. Lua makes a point to use %.14g instead of %.17g in
tostring. See http://lua-users.org/lists/lua-l/2004-12/msg00027.html