lua-users home
lua-l archive

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


It was thus said that the Great Roberto Ierusalimschy once stated:
> 
> One problem with all proposed solutions is math.mininteger. The
> lexer reads numbers without signal. (Several languages do the
> same, e.g. C).  This means that -9223372036854775808 is read as
> -(9223372036854775808) (a unary minus applied over a positive
> constant). But 9223372036854775808 is not a valid integer, so it would
> result in a float (or nil, or inf, or error). Whatever the choice, the
> final value of -9223372036854775808 would not be an integer, despite
> it being a valid integer.

  I haven't looked at the code, but couldn't the lexer read the minus sign
and set a flag. Then read in the number as an unsigned quantity and as long
as it's not a float (no decimal point, no 'e' or 'E', etc.) then check
against LLONG_MIN and LLONG_MAX? 9223372036854775808 *is* representable as
an unsigned quantity.

  -spc