I see the benefit of not relying on the binary representation. But
still, this hash only really makes sense for doubles. And then, simply
using the first 32 bits would achieve something similar, i.e. hashing
close numbers to the same value in less cycles.

Why is hashing close numbers to the same value a benefit? Especially for
hash tables I think it would be good to avoid situations where
collisions can be produced systematically easily.


On Fri, 18 Mar 2011, Mirar @ Pike  developers forum wrote:

I think I would still say something like

q = 2000000000 + round(log(f)*1000000);

which has the benefit of being portable and that numbers that are
close to each other will hash to the same values.

Special cases is needed for inf and nan, though.

  • float hashing Arne Goedeke
    • float hashing Mirar @ Pike developers forum
      • Re: float ha... Arne Goedeke
        • Re: floa... Mirar @ Pike developers forum
          • Re: ... Arne Goedeke
            • ... Mirar @ Pike developers forum
              • ... Arne Goedeke
                • ... Martin Stjernholm, Roxen IS @ Pike developers forum
                • ... Martin Stjernholm, Roxen IS @ Pike developers forum
                • ... Arne Goedeke
                • ... Martin Stjernholm, Roxen IS @ Pike developers forum
                • ... Arne Goedeke
                • ... Arne Goedeke
                • ... Martin Stjernholm, Roxen IS @ Pike developers forum
                • ... Arne Goedeke
                • ... Arne Goedeke
                • ... Martin Stjernholm, Roxen IS @ Pike developers forum

Reply via email to