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

Fix FloatOrd hash being different for different NaN values #618

Merged
merged 2 commits into from
Oct 3, 2020
Merged

Fix FloatOrd hash being different for different NaN values #618

merged 2 commits into from
Oct 3, 2020

Conversation

andrewhickman
Copy link
Contributor

There are multiple representations of NaN possible. The Eq impl treats them as equal, so the Hash impl should hash them to the same value as well.

@andrewhickman
Copy link
Contributor Author

andrewhickman commented Oct 2, 2020

I think NaN and zeroes are the only two cases where float equality is different to byte equality (Going by https://en.wikipedia.org/wiki/IEEE_754-1985#Comparing_floating-point_numbers). It wouldn't surprise me to learn of more weird edge cases though...

@cart
Copy link
Member

cart commented Oct 2, 2020

yeah floats are wild. in this case, im totally cool with iteratively improving as more differences are discovered.

@karroffel karroffel added the C-Code-Quality A section of code that is hard to understand or change label Oct 3, 2020
@cart cart merged commit 9a4167e into bevyengine:master Oct 3, 2020
mrk-its pushed a commit to mrk-its/bevy that referenced this pull request Oct 6, 2020
…e#618)

* Fix FloatOrd hash being different for different NaN values

* Fix FloatOrd hashing +0.0 and -0.0 to different values
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-Code-Quality A section of code that is hard to understand or change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants