[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Unsigned Integer Literals?
- From: Muh Muhten <muh.muhten@...>
- Date: Mon, 3 Dec 2018 23:43:24 -0500
On 12/3/18, Philippe Verdy <email@example.com> wrote:
> Le mar. 4 déc. 2018 à 00:11, Muh Muhten <firstname.lastname@example.org> a écrit :
>> On 12/3/18, Magicks M <email@example.com> wrote:
>> > Quoting from Programming in lua:
>> >> We can write constants larger than 2^63 -1 directly, despite
>> > > x = 13835058055282163712 -- 3 << 62
>> > > x --> -4611686018427387904
>> > When I enter this example into an interpreter (you can try in the lua
>> > the number is cast to a float, is that supposed to happen?
>> Since this numeric constant has neither radix point nor exponent, and
>> does not fit in an integer, it is not defined by the manual (§3.1):
>> > A numeric constant with a radix point or an exponent denotes a float;
>> otherwise, if its value fits in an integer, it denotes an integer.
>> 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
> But this integer exists ! The expression (-2147483647 - 1) uses only
> integers within the positive subset, and produces an integer, even if its
> negation would produce a double with the Lua operator. This is the only
> integer (assuming integers are 32 bits) that has no distinct negation as an
> If integers are compiled as 64-bit (normally the case on 64-bit target
> architecture where the C "int" type is 64-bit), then the unique integer
> without distinct negation is (-9223372036854775807-1).
> You may still have not understood this issue.
13835058055282163712 does not fit in a 64-bit integer.