lua-users home
lua-l archive

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


On Fri, 7 Feb 2020 at 12:23, Egor Skriptunoff
<egor.skriptunoff@gmail.com> wrote:
>
> On Fri, Feb 7, 2020 at 1:35 PM Hisham wrote:
>>
>> Is this the only difference
>> you are aware of?
>>
>
> LuaJIT has a quirk with converting out-of-range values
> from "double" to "int64":
> For example, bit.bor(2^64, 0LL) is negative
> Another example (convert -1.0 to uint64):
> for j = 0, 100 do
>    local m1 = #{j} * (-1)       -- minus one of type "double"
>    local zero = bit.bor(m1, 0ULL) + 1 -- must be zero, but...
>    if j % 100 == 0 then print(zero) end
> end

Wat -- that is just a plain _bug_, right?

This:

for j = 0, 100 do local m1 = -1.0; local zero = bit.bor(m1, 0ULL) + 1;
print(j, zero); end

and this:

for j = 0, 100 do local m1 = -1.0; print(m1); local zero = bit.bor(m1,
0ULL) + 1; print(j, zero); end

...produce different results on LuaJIT (the only different is printing
m1 in between.

-- Hisham