-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Comments
mbrubeck
added a commit
to mbrubeck/rust
that referenced
this issue
Oct 28, 2011
brson
pushed a commit
that referenced
this issue
Oct 28, 2011
Fixed by #1090. |
bors
pushed a commit
to rust-lang-ci/rust
that referenced
this issue
Dec 20, 2021
coastalwhite
pushed a commit
to coastalwhite/rust
that referenced
this issue
Aug 5, 2023
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
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.
The text was updated successfully, but these errors were encountered: