lua-users home
lua-l archive

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


> On 19/04/2011 19:10, Roberto Ierusalimschy wrote:
> >Lua 5.1 manual - http://www.lua.org/manual/5.1/manual.html#pdf-tonumber
> >
> >   In other [different from 10] bases, only unsigned integers are accepted.
> 
> I forgot about this one. There must be a reason for that, as it
> seems as an unnecessary limitation? (I was just bitten by that in my
> app).

It was caused by the use of strtou. (With strtol, we would have problems
with values greater than 2^31.) But in fact there is a bug there. If
the string is not a valid number, 'tonumber' should return nil. Unlike
some other functions, 'tonumber' should work with any argument.

-- Roberto