lua-users home
lua-l archive

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


Okay, I'm somewhat surprised that this was removed on purpose since it kind of introduces a breaking change but thanks for explaining. I totally get why this isn't something you'd necessarily want. If you could link to the previous list on the archive that would be cool 

On Tue, 4 Dec 2018, 08:30 Dirk Laurie <dirk.laurie@gmail.com wrote:
No. "Do not call something 'bug' that does not behave as you wanted or
expected. — Roberto"

It was a deliberate decision, after debate on the list. It is less
confusing for the type of user who does not quite understand two's
complements if decimal literals became floats rather than
underflowing, and those that do understand it also understand hex, so
they do not need decimal notation.

PiL 4 appeared in August 2016, before Lua got to 5.3.4, and anyway it
is not the User's Manual. You can't expect a once-per-version book to
be kept in sync with minor releases.
Op Di. 4 Des. 2018 om 09:53 het Magicks M <m4gicks@gmail.com> geskryf:
>
> 5.3.5 is also affected, I'm guessing 5.3.4 introduced this and it's a bug then?
>
> On Tue, Dec 4, 2018 at 5:42 AM Dirk Laurie <dirk.laurie@gmail.com> wrote:
>>
>> 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
>> ask?" There is no answer that satisfies everybody. The answer finally
>> 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.
>>