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 comparisons in Rust do not follow IEEE 754 #1084

Closed
mbrubeck opened this issue Oct 28, 2011 · 1 comment
Closed

Floating point comparisons in Rust do not follow IEEE 754 #1084

mbrubeck opened this issue Oct 28, 2011 · 1 comment

Comments

@mbrubeck
Copy link
Contributor

For example, (NaN == NaN) is true in Rust but false in IEEE 754. As explained in #1083, this is intentional and the goal is to make == and < act consistently so that NaN can be used as a key in ordered collections, for example.

One downside of this is that programmers cannot apply knowledge or techniques learned from languages like Java or JavaScript that use IEEE 754 floating-point arithmetic.

Another problem is that differences between Rust and IEEE 754 are not specified, and do not appear to be implemented consistently. This makes it hard to know what to expect from Rust. Issue #1083 lists more problems with the current Rust semantics of NaN, but it is not clear which are intentional and which are not.

If this issue is closed as WONTFIX, then we should instead open a new issue to document Rust's floating point semantics.

@mbrubeck
Copy link
Contributor Author

Fixed by #1090.

bors pushed a commit to rust-lang-ci/rust that referenced this issue Dec 20, 2021
celinval added a commit to celinval/rust-dev that referenced this issue Jun 4, 2024
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

1 participant