lua-users home
lua-l archive

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


To me this raises the question as to whether the way out of the CRT mess
is to implement as part of standard Lua the function ua_str2number().
Restated the implementation of lua_str2number().is provided.
As Rici has demonstrated, it is not a lot of code.
So rather than having everyone complain about variant behaviours with
strtod() we could solve the problem with lua_strtod().
And maybe the same can be said for strtoul().

Agreement anyone?

db


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

Get it here: http://primero.ricilake.net/lua/xstrtod.c