Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Floating point numbers. #2

Open
antialize opened this issue Oct 30, 2014 · 1 comment
Open

Floating point numbers. #2

antialize opened this issue Oct 30, 2014 · 1 comment

Comments

@antialize
Copy link

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
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants