• Subject: Re: Unsigned Integer Literals?
• From: Dirk Laurie <dirk.laurie@...>
• Date: Tue, 4 Dec 2018 07:42:09 +0200

```Op Di. 4 Des. 2018 om 01:11 het Muh Muhten <muh.muhten@gmail.com> geskryf:
> On 12/3/18, Magicks M <m4gicks@gmail.com> wrote:
> > Quoting from Programming in lua:
> >
> >> We can write constants larger than 2^63 -1 directly, despite appearances:
> >>
> >   > x = 13835058055282163712 -- 3 << 62
> >>
> >  > x                        --> -4611686018427387904
> >>
> > When I enter this example into an interpreter (you can try in the lua demo)
> > the number is cast to a float, is that supposed to happen?

> The claim in PIL is consistent with 5.3.0-2, but changed in 5.3.3. The
> manual text in that section is the same. Of course, pre-5.3 versions
> generally have the "new" behaviour due to using only floating-point
> numbers.

My "make linux" directly from source has it only in 5.3.4.

\$ /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
\$ /usr/local/src/lua-5.3.4/src/lua
Lua 5.3.4  Copyright (C) 1994-2017 Lua.org, PUC-Rio
> n=13835058055282163712; print(n)
1.3835058055282e+19

We argued this question ad nauseam on the lista few years ago. It
belongs to the category "What should Lua do if it can't do what you
selected serves the purpose of giving a visual clue that there has
been overflow.

Note that only decimal input is affected: hex is still the same;
numbers generated by arithmetic (except /) on integers are integers.

Lua 5.3.4  Copyright (C) 1994-2017 Lua.org, PUC-Rio
> n=0xc000000000000000; print(n)
-4611686018427387904

Personally I dont mind hex. I can't recognize numbers in written
decimal as powers of 2 when they go past 65536. I don't think the
readibilty of code is served by writing numbers like
13835058055282163712.

```