[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua5 / poor performance
- From: "Wim Couwenberg" <w.couwenberg@...>
- Date: Thu, 20 Mar 2003 21:53:28 +0100
Hi,
Peter S. Housel:
> A more portable, and very fast, method of hashing floating-point numbers
> might be:
>
> 1) Extract the manitssa and exponent using frexp() function.
> 2) Multiply the mantissa by (double) 2^(bits in a long - 1)
> 3) Truncate the multiplication result to a long
> 4) Hash this result with together with the exponent
My thoughts exactly! I was wondering if replacing the multiply by an ldexp
call could perhaps be quicker? You can also "shift out" enough parts of the
mantissa to exhaust its precision (to avoid collisions for values that are
very close.)
Bye,
Wim