lua-users home
lua-l archive

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


2013/7/6 Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br>:

> Lua 5.3.0 (work1) is now available for testing at
>         http://www.lua.org/work/lua-5.3.0-work1.tar.gz

> The main change in Lua 5.3.0 is support for integers.

Big gotcha: ^ behaves like //.

$ lua
Lua 5.2.2  Copyright (C) 1994-2013 Lua.org, PUC-Rio
> =2^64
1.844674407371e+19
> return 2^63
9.2233720368548e+18
> return 2^62
4.6116860184274e+18

$ ./lua
Lua 5.3.0 (work1)  Copyright (C) 1994-2013 Lua.org, PUC-Rio
> =2^64
0
> return 2^63
-9223372036854775808
> return 2^62
4611686018427387904

Note that the true 2^64 and 2^63 are exact floating-point numbers.

Some preferable alternatives:

1. ^ behaves like / and a new ^^ behaves like //.
2. Catch integer overflow, and one of:
   2a. Throw an error.
   2b. Return nil.
   2c. Do it in float instead.