lua-users home
lua-l archive

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




On 16/07/16 04:38 PM, Philipp Janda wrote:
Am 16.07.2016 um 21:17 schröbte Soni L.:

On 16/07/16 12:15 PM, Philipp Janda wrote:

Doing the interning and equivalence class thing during construction of
your bigints instead of during table indexing has the added advantage,
that `100 == bigint(100)` works as well, that something like
`table.insert({}, bigint(1), x)` works as well, and that it's probably
also faster.

And then you have bigint(2^62) + bigint(2^62) == bigint(-2^63)

Sure. Can happen with `__key` as well (although better hidden):

    local t = { [ bigint( 2^62 ) ] = true }
    next( t ) + next( t ) == -2^63

Just like this? (Lua 5.3.3)

local t = { [1] = "test" }
print(math.type(next(t))) --> integer
t[1.0] = "test"
print(math.type(next(t))) --> integer
t[1] = nil
t[1.0] = "test"
print(math.type(next(t))) --> integer

As well:

local t = { [2^62] = "test" }
print(math.type(next(t)), math.type(2^62)) --> integer float

I'm not sure what your point here is.


Maybe `bigint(n)` is not really supposed to be equivalent to integer `n`.

Philipp





--
Disclaimer: these emails may be made public at any given time, with or without reason. If you don't agree with this, DO NOT REPLY.