lua-users home
lua-l archive

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




Le mar. 4 déc. 2018 à 06:42, Dirk Laurie <dirk.laurie@gmail.com> a écrit :
Op Di. 4 Des. 2018 om 01:11 het Muh Muhten <muh.muhten@gmail.com> geskryf:
$ /usr/local/src/lua-5.3.3/src/lua
Lua 5.3.3  Copyright (C) 1994-2016 Lua.org, PUC-Rio
> n=13835058055282163712; print(n)
-4611686018427387904
 [...]
Lua 5.3.4  Copyright (C) 1994-2017 Lua.org, PUC-Rio
> n=0xc000000000000000; print(n)
-4611686018427387904

Personally I call these two examples "bugs" because they generate the incorrect values.

Lua treats numbers only (there's a single exposed type), and is supposed to rewrite integers using doubles only if they don't fit the expected limited range, but should NEVER underflow.

Because it confuses the treatment of doubles as well without being even consistant with integers. Integers in Lua should be internal optimization of doubles, each time this is possible. It should not depend on the fact we use a ".0" or exponential notation or none when writing constants or serializing them as strings and parsing strings.