HowardHinnant / hash_append

Implementation of hash_append proposal
68 stars 13 forks source link

Floating point numbers. #2

Open antialize opened 10 years ago

antialize commented 10 years ago

When hashing floats. You seem to handle plus and minus zero as the same value (as you should). In floats there are many different NAN values, that generally fall into thee classes, -infinity, +infinity and "the rest". Do you not agree that all floats in the "the rest" class should hash to the same value? In boost they switch over the result of std::fpclassify when hashing floats.

HowardHinnant commented 10 years ago

infinity and -infinity compare not equal and have different bit patterns, and thus different hash codes. All is well there.

Nans are a different story. nan != nan, irregardless of the bit pattern representing the nan. This is sufficiently troublesome that nans today don't go into any associative or unordered container using the default comparators. To date, this proposal has done nothing to change that: nans are still not supported by default.