graydon/rust — Issue #1084: Floating point comparisons in Rust do not follow IEEE 754
Author: mbrubeck
Created: 2011-10-28 03:59:30+00:00
State: open

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.