[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Numeric key collision related bug in Lua 5.3
- From: Roberto Ierusalimschy <roberto@...>
- Date: Thu, 23 Apr 2015 05:04:44 -0300
> The problem is the current definition of equality. The way it is
> defined (compare integer-float converting the integer to float) makes
> it non transitive:
>
> > t1 = (1<< 62) + 1
> > t2 = t1 + 2
> > t3 = t1 + 0.0 -- will be rounded to 2^62
> > print(t1 == t3, t2 == t3, t1 == t2)
> --> true true false
>
> That is all good, until you try to put these values as indices
> in a table. Because there is no transitivity, there is no
> partition. Dependening on the order that these elements are compared
> to each other, they will collide (or not) in different ways.
Note that key tables are normalied to integers when possible, so this
problem only occurrs with 2^64. This is the only float value that can
be equal to an integer value (according to the old/current equality
definition) but cannot be converted to an integer.
-- Roberto