------- Additional Comments From tneumann at pi3 dot informatik dot 
uni-mannheim dot de  2005-07-06 07:42 -------
How about using a union-cast to hash floating point numbers? Something like this

unsigned hash(double v) {
   union { double a; unsigned long long b; } tmp;
   tmp.a=v; return tmp.b^(tmp.b>>32);
}

The code is only a sketch (assumes 32bit unsigned etc.) but should produce much 
better results than the current hash function. It should also avoid the 
problems 
with unordered_set<double> mentioned on the mailing list.
The main disadvantage is that it forces memory access, which is somewhat slow.
Another problem is that the resulting hash value is not portable, but this is 
probably ok.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21193

Reply via email to