-
Notifications
You must be signed in to change notification settings - Fork 14k
clarify float min/max behavios for NaNs and signed zeros #149239
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
base: main
Are you sure you want to change the base?
Conversation
fd218fe to
500033d
Compare
This comment has been minimized.
This comment has been minimized.
500033d to
6ddca27
Compare
library/core/src/intrinsics/mod.rs
Outdated
| /// | ||
| /// If one of the arguments is NaN, then the other argument is returned. If the inputs compare equal | ||
| /// (such as for the case of `+0.0` and `-0.0`), either input may be returned non-deterministically. | ||
| /// The last point makes this not quite the same as IEEE 754-2008 minNum. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I think I misunderstood here -- looking at the 2008 version of the standard, it says
minNum(x, y) is the canonicalized number x if x < y, y if y < x, the canonicalized number if one
operand is a number and the other a quiet NaN. Otherwise it is either x or y, canonicalized (this
means results might differ among implementations). When either x or y is a signalingNaN, then the
result is according to 6.2.
So what we do actually does exactly match IEEE 754-2008 minNum, except for the usual differences in NaN treatment.
6ddca27 to
8b87b25
Compare
The first comment is internal, it only documents the intrinsics to more clearly say what they do.
This makes the currently implemented semantics more explicit, so one does not have to go look for the publicly exposed version of the operation to figure out what exactly should happen.
The second commit adds a NaN test to the doc comment for
min/max, which matches what we already have forminimum/maximum.