Closed
Description
Floating-point semantics are hard, in particular the NaN part, but this should describe them accurately -- except on x86-32, for more than one reason.
We still need to officially decide that those are our intended semantics though. rust-lang/rust#73328 tracks that on the rustc side.
Historic info
There are several ways in which our de-facto FP semantics currently are broken:
- LLVM doesn't preserve NaN bits (which is likely incoherent). That's Document guarantees (or lack thereof) regarding sign, quietness, and payload of
NaN
s rust#73328, which is a meta-issue. Specific issues: Wrong signs on division producing NaN rust#55131 (on all platforms) - LLVM uses the x87 instructions and registers on i686 which behave different from how IEEE floats should behave. That's Comparing to infinity is buggy on x87 rust#72327 (without SSE2) and i686 floating point behavior does not agree with unit tests in debug mode rust#73288 (with SSE2).
- LLVM does not distinguish sNaN and qNaN the way IEEE mandates: Rust does not comply with IEEE 754 floats: arithmetic can produce signaling NaN rust#107247.
I'm adding this here because figuring out the semantics of Rust is part of the goal of the UCG (I think?) and we should have an overarching "FP semantics" tracker somewhere.