Skip to content

Commit 78efb07

Browse files
committed
review the total_cmp documentation
The documentation has been restructured to split out a brief summary paragraph out from the following elaborating paragraphs. I also attempted my hand at wording improvements and adding articles where I felt them missing, but being non-native english speaker these may need more thorough review.
1 parent 8c7f2bf commit 78efb07

File tree

2 files changed

+54
-38
lines changed

2 files changed

+54
-38
lines changed

library/core/src/num/f32.rs

+27-19
Original file line numberDiff line numberDiff line change
@@ -1008,29 +1008,37 @@ impl f32 {
10081008
Self::from_bits(u32::from_ne_bytes(bytes))
10091009
}
10101010

1011-
/// Returns an ordering between self and other values.
1011+
/// Return the ordering between `self` and `other`.
1012+
///
10121013
/// Unlike the standard partial comparison between floating point numbers,
10131014
/// this comparison always produces an ordering in accordance to
1014-
/// the totalOrder predicate as defined in IEEE 754 (2008 revision)
1015-
/// floating point standard. The values are ordered in following order:
1016-
/// - Negative quiet NaN
1017-
/// - Negative signaling NaN
1018-
/// - Negative infinity
1019-
/// - Negative numbers
1020-
/// - Negative subnormal numbers
1021-
/// - Negative zero
1022-
/// - Positive zero
1023-
/// - Positive subnormal numbers
1024-
/// - Positive numbers
1025-
/// - Positive infinity
1026-
/// - Positive signaling NaN
1027-
/// - Positive quiet NaN
1028-
///
1029-
/// Note that this function does not always agree with the [`PartialOrd`]
1030-
/// and [`PartialEq`] implementations of `f32`. In particular, they regard
1031-
/// negative and positive zero as equal, while `total_cmp` doesn't.
1015+
/// the `totalOrder` predicate as defined in the IEEE 754 (2008 revision)
1016+
/// floating point standard. The values are ordered in the following sequence:
1017+
///
1018+
/// - negative quiet NaN
1019+
/// - negative signaling NaN
1020+
/// - negative infinity
1021+
/// - negative numbers
1022+
/// - negative subnormal numbers
1023+
/// - negative zero
1024+
/// - positive zero
1025+
/// - positive subnormal numbers
1026+
/// - positive numbers
1027+
/// - positive infinity
1028+
/// - positive signaling NaN
1029+
/// - positive quiet NaN.
1030+
///
1031+
/// The ordering established by this function does not always agree with the
1032+
/// [`PartialOrd`] and [`PartialEq`] implementations of `f32`. For example,
1033+
/// they consider negative and positive zero equal, while `total_cmp`
1034+
/// doesn't.
1035+
///
1036+
/// The interpretation of the signaling NaN bit follows the definition in
1037+
/// the IEEE 754 standard, which may not match the interpretation by some of
1038+
/// the older, non-conformant (e.g. MIPS) hardware implementations.
10321039
///
10331040
/// # Example
1041+
///
10341042
/// ```
10351043
/// #![feature(total_cmp)]
10361044
/// struct GoodBoy {

library/core/src/num/f64.rs

+27-19
Original file line numberDiff line numberDiff line change
@@ -1024,29 +1024,37 @@ impl f64 {
10241024
Self::from_bits(u64::from_ne_bytes(bytes))
10251025
}
10261026

1027-
/// Returns an ordering between self and other values.
1027+
/// Return the ordering between `self` and `other`.
1028+
///
10281029
/// Unlike the standard partial comparison between floating point numbers,
10291030
/// this comparison always produces an ordering in accordance to
1030-
/// the totalOrder predicate as defined in IEEE 754 (2008 revision)
1031-
/// floating point standard. The values are ordered in following order:
1032-
/// - Negative quiet NaN
1033-
/// - Negative signaling NaN
1034-
/// - Negative infinity
1035-
/// - Negative numbers
1036-
/// - Negative subnormal numbers
1037-
/// - Negative zero
1038-
/// - Positive zero
1039-
/// - Positive subnormal numbers
1040-
/// - Positive numbers
1041-
/// - Positive infinity
1042-
/// - Positive signaling NaN
1043-
/// - Positive quiet NaN
1044-
///
1045-
/// Note that this function does not always agree with the [`PartialOrd`]
1046-
/// and [`PartialEq`] implementations of `f64`. In particular, they regard
1047-
/// negative and positive zero as equal, while `total_cmp` doesn't.
1031+
/// the `totalOrder` predicate as defined in the IEEE 754 (2008 revision)
1032+
/// floating point standard. The values are ordered in the following sequence:
1033+
///
1034+
/// - negative quiet NaN
1035+
/// - negative signaling NaN
1036+
/// - negative infinity
1037+
/// - negative numbers
1038+
/// - negative subnormal numbers
1039+
/// - negative zero
1040+
/// - positive zero
1041+
/// - positive subnormal numbers
1042+
/// - positive numbers
1043+
/// - positive infinity
1044+
/// - positive signaling NaN
1045+
/// - positive quiet NaN.
1046+
///
1047+
/// The ordering established by this function does not always agree with the
1048+
/// [`PartialOrd`] and [`PartialEq`] implementations of `f64`. For example,
1049+
/// they consider negative and positive zero equal, while `total_cmp`
1050+
/// doesn't.
1051+
///
1052+
/// The interpretation of the signaling NaN bit follows the definition in
1053+
/// the IEEE 754 standard, which may not match the interpretation by some of
1054+
/// the older, non-conformant (e.g. MIPS) hardware implementations.
10481055
///
10491056
/// # Example
1057+
///
10501058
/// ```
10511059
/// #![feature(total_cmp)]
10521060
/// struct GoodBoy {

0 commit comments

Comments
 (0)