[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: lexical parse of hex literal fails to handle overflow: lua 5.3 and 5.4-alpha
- From: Andrew Gierth <andrew@...>
- Date: Thu, 26 Mar 2020 20:36:37 +0000
>>>>> "Payo" == Payo Nel <payonel@hotmail.com> writes:
Payo> the parser also incorrectly "upgrades" a valid integer to a float
Payo> value with a minimum integer value:
Payo> tonumber is correct here:
Payo> > tonumber('-9223372036854775808',10)
Payo> -9223372036854775808
Payo> lexical parse is not
Payo> > -9223372036854775808
Payo> -9.2233720368548e+18
That's because this parses as -(9223372036854775808) so it overflows
before the - operator is applied. This is an issue common to many
languages.
--
Andrew.