3 ms·
What is wrong in having different hashes for different numbers? https://float.exposed/0x0000000000000000 https://float.exposed/0x0000000000000000 https://floa
by emergie 6y ago
What is wrong in having different hashes for different numbers?
https://float.exposed/0x0000000000000000 https://float.exposed/0x0000000000000000
https://float.exposed/0x8000000000000000 https://float.exposed/0x8000000000000000
- magicalhippo 6y agoIf you compare for equality then those two numbers, 0.0 and -0.0, are considered equal. It seems a lot of people consider that a good reason for them to have the same hash value, which I consider entirely fairly reasonable. Of course since NaN != x, whatever x is (including infinity and NaN), one could argue it's fine for different NaNs to return different hash codes. But I think most people think of NaN as one thing, and not the 9007199254740990 or so different NaN encodings[1] there are in a double. [1]: https://en.wikipedia.org/wiki/IEEE_754-1985#NaN https://en.wikipedia.org/wiki/IEEE_754-1985#NaN