lua-users home
lua-l archive

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


Hi,

Rici Lake wrote:
> On 29-Jan-07, at 5:12 PM, Mike Pall wrote:
> >The behaviour of number parsing and output is system dependent
> >because Lua uses the library functions provided by the toolchain.
> >This makes sense because some implementations need more lines of
> >code for this task than Lua itself. ;-)
> 
> OK, it's a little longer than I hoped it might be (127 including 
> comments and test driver / 72 actually in the function) but it's still 
> somewhat smaller than Lua. Of course, it only does hex floats (doubles, 
> actually, but a simple %s/double/float/g should fix that.)

One of my ancient patches for Lua 5.1alpha has a 10-liner which
handles non-fractional hex-numbers with full lua_Number
precision. This is probably sufficient for the OP:
  http://lua-users.org/lists/lua-l/2005-09/msg00158.html

Just to put the quoted statement in context: I was referring to
the inherent difficulty of parsing and printing of _decimal_
numbers to/from binary floating-point representations. This needs
much more code. If anyone has ever wondered why glibc includes
lots of GMP functions, here's the reason:
  http://lua-users.org/lists/lua-l/2004-12/msg00041.html

Bye,
     Mike