Improve wording of "NaN as a special value" top level explanation

This commit is contained in:
Pyry Kontio 2022-03-31 11:27:23 +09:00
parent fff5a06f28
commit 4ee8b64a81
2 changed files with 10 additions and 8 deletions

View file

@ -978,14 +978,15 @@ mod prim_tuple {}
/// - [NaN (not a number)](#associatedconstant.NAN): this value results from
/// calculations like `(-1.0).sqrt()`. NaN has some potentially unexpected
/// behavior:
/// - It is unequal to any float, including itself!
/// - It is unequal to any float, including itself! This is the reason `f32`
/// doesn't implement the `Eq` trait.
/// - It is also neither smaller nor greater than any float, making it
/// impossible to sort by the default comparison operation. This is the
/// reason `f32` doesn't implement the `Ord` and `Eq` traits.
/// impossible to sort by the default comparison operation, which is the
/// reason `f32` doesn't implement the `Ord` trait.
/// - It is also considered *infectious* as almost all calculations where one
/// of the operands is NaN will also result in NaN. The explanations on this
/// page only explicitly document behavior on NaN operands if this default
/// is *not* observed by the operation.
/// is deviated from.
/// - Lastly, there are multiple bit patterns that are considered NaN.
/// Rust does not currently guarantee that the bit patterns of NaN are
/// preserved over arithmetic operations,