[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
**Subject**: **Re: Proposal: Constant Tables**
**From**: Dirk Laurie <dpl@...>
**Date**: Sat, 13 Aug 2011 16:28:09 +0200

On Sat, Aug 13, 2011 at 04:12:01PM +0200, Gregory Bonik wrote:
>
> Beware of floating point non-associativity here. (k, v) pairs can come
> in different order depending on the table's usage history. Combined with
> non-associativity of addition, this can theoretically result in
> different hashes for identical tables. Of course, this problem is not
> likely to occur, but I wouldn't use such solution in a critical part of
> code.
>
> You should probably use math.random(N) with some integer N instead of
> math.random() and carry out addition by some integer modulo instead of
> just hash_key = hash_key + pair_key(k,v).
>
Lua 5.2 has bit32.bxor, which is fully associative and commutative.
D.