lua-users home
lua-l archive

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



On 29-Jan-07, at 8:17 PM, Mike Pall wrote:

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


Perhaps for the OP, but I personally think hex floats are a really useful interchange format, particularly now that compiled bytecode isn't.

I'm not going to win any awards for the efficiency of my code, but it should work just fine on any platform with floating point support.

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.

Sure, I was being a bit tongue-in-cheek. Correctly converting between decimal and binary floating point, and doing so correctly, is really difficult (and a lot of c libraries don't bother with the edge cases, including Windows if I'm not mistaken). However, I would be content with there being some form of interchange that had a reasonable probability of moving from platform to platform; I'm prepared to accept sloppy platform library decimal conversion if there's an alternative.

R.