[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: tonumber() on negative hexadecimal strings
- From: Roberto Ierusalimschy <roberto@...>
- Date: Wed, 20 Apr 2011 14:47:24 -0300
> >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.
>
> So, tonumber("-0x10") should return nil ?
My point is that either tonumber accepts "-0x10", and therefore
returns the correct value, or it does not accept it, and therefore
returns nil. There is no other option.
> Just spotted another issue (could be a documentation issue): docs
> say that the default for `base' is 10, but in fact, if the first
> argument starts with 0x then the default is 16.
This is a "documentation issue"; thanks.
-- Roberto