Skip to content

Commit 4ee8b64

Browse files
committed
Improve wording of "NaN as a special value" top level explanation
1 parent fff5a06 commit 4ee8b64

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

library/core/src/primitive_docs.rs

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

library/std/src/primitive_docs.rs

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

0 commit comments

Comments
 (0)