@@ -1038,7 +1038,8 @@ public protocol FloatingPoint: SignedNumeric, Strideable, Hashable {
1038
1038
///
1039
1039
/// - Parameter other: The value to compare with this value.
1040
1040
/// - Returns: `true` if `other` has the same value as this instance;
1041
- /// otherwise, `false`.
1041
+ /// otherwise, `false`. If either this value or `other` is NaN, the result
1042
+ /// of this method is `false`.
1042
1043
func isEqual( to other: Self ) -> Bool
1043
1044
1044
1045
/// Returns a Boolean value indicating whether this instance is less than the
@@ -1068,7 +1069,9 @@ public protocol FloatingPoint: SignedNumeric, Strideable, Hashable {
1068
1069
/// [spec]: http://ieeexplore.ieee.org/servlet/opac?punumber=4610933
1069
1070
///
1070
1071
/// - Parameter other: The value to compare with this value.
1071
- /// - Returns: `true` if `other` is less than this value; otherwise, `false`.
1072
+ /// - Returns: `true` if this value is less than `other`; otherwise, `false`.
1073
+ /// If either this value or `other` is NaN, the result of this method is
1074
+ /// `false`.
1072
1075
func isLess( than other: Self ) -> Bool
1073
1076
1074
1077
/// Returns a Boolean value indicating whether this instance is less than or
@@ -1096,33 +1099,33 @@ public protocol FloatingPoint: SignedNumeric, Strideable, Hashable {
1096
1099
/// [spec]: http://ieeexplore.ieee.org/servlet/opac?punumber=4610933
1097
1100
///
1098
1101
/// - Parameter other: The value to compare with this value.
1099
- /// - Returns: `true` if `other` is less than this value; otherwise, `false`.
1102
+ /// - Returns: `true` if `other` is greater than this value; otherwise,
1103
+ /// `false`. If either this value or `other` is NaN, the result of this
1104
+ /// method is `false`.
1100
1105
func isLessThanOrEqualTo( _ other: Self ) -> Bool
1101
1106
1102
- /// Returns a Boolean value indicating whether this instance should precede the
1103
- /// given value in an ascending sort.
1107
+ /// Returns a Boolean value indicating whether this instance should precede
1108
+ /// or tie positions with the given value in an ascending sort.
1104
1109
///
1105
1110
/// This relation is a refinement of the less-than-or-equal-to operator
1106
1111
/// (`<=`) that provides a total order on all values of the type, including
1107
- /// noncanonical encodings, signed zeros, and NaNs. Because it is used much
1108
- /// less frequently than the usual comparisons, there is no operator form of
1109
- /// this relation.
1112
+ /// signed zeros and NaNs.
1110
1113
///
1111
- /// The following example uses `isTotallyOrdered(below :)` to sort an array of
1112
- /// floating-point values, including some that are NaN:
1114
+ /// The following example uses `isTotallyOrdered(belowOrEqualTo :)` to sort an
1115
+ /// array of floating-point values, including some that are NaN:
1113
1116
///
1114
1117
/// var numbers = [2.5, 21.25, 3.0, .nan, -9.5]
1115
- /// numbers.sort { $0 .isTotallyOrdered(below : $1 ) }
1116
- /// // numbers == [-9.5, 2.5, 3.0, 21.25, nan ]
1118
+ /// numbers.sort { !$1 .isTotallyOrdered(belowOrEqualTo : $0 ) }
1119
+ /// // numbers == [-9.5, 2.5, 3.0, 21.25, NaN ]
1117
1120
///
1118
1121
/// The `isTotallyOrdered(belowOrEqualTo:)` method implements the total order
1119
1122
/// relation as defined by the [IEEE 754 specification][spec].
1120
1123
///
1121
1124
/// [spec]: http://ieeexplore.ieee.org/servlet/opac?punumber=4610933
1122
1125
///
1123
1126
/// - Parameter other: A floating-point value to compare to this value.
1124
- /// - Returns: `true` if this value is ordered below `other` in a total
1125
- /// ordering of the floating-point type; otherwise, `false`.
1127
+ /// - Returns: `true` if this value is ordered below or the same as `other`
1128
+ /// in a total ordering of the floating-point type; otherwise, `false`.
1126
1129
func isTotallyOrdered( belowOrEqualTo other: Self ) -> Bool
1127
1130
1128
1131
/// A Boolean value indicating whether this instance is normal.
@@ -2029,30 +2032,28 @@ extension BinaryFloatingPoint {
2029
2032
significandBitPattern: magnitudeOf. significandBitPattern)
2030
2033
}
2031
2034
2032
- /// Returns a Boolean value indicating whether this instance should precede the
2033
- /// given value in an ascending sort.
2035
+ /// Returns a Boolean value indicating whether this instance should precede
2036
+ /// or tie positions with the given value in an ascending sort.
2034
2037
///
2035
2038
/// This relation is a refinement of the less-than-or-equal-to operator
2036
2039
/// (`<=`) that provides a total order on all values of the type, including
2037
- /// noncanonical encodings, signed zeros, and NaNs. Because it is used much
2038
- /// less frequently than the usual comparisons, there is no operator form of
2039
- /// this relation.
2040
+ /// signed zeros and NaNs.
2040
2041
///
2041
- /// The following example uses `isTotallyOrdered(below :)` to sort an array of
2042
- /// floating-point values, including some that are NaN:
2042
+ /// The following example uses `isTotallyOrdered(belowOrEqualTo :)` to sort an
2043
+ /// array of floating-point values, including some that are NaN:
2043
2044
///
2044
2045
/// var numbers = [2.5, 21.25, 3.0, .nan, -9.5]
2045
- /// numbers.sort { $0 .isTotallyOrdered(below : $1 ) }
2046
- /// // numbers == [-9.5, 2.5, 3.0, 21.25, nan ]
2046
+ /// numbers.sort { !$1 .isTotallyOrdered(belowOrEqualTo : $0 ) }
2047
+ /// // numbers == [-9.5, 2.5, 3.0, 21.25, NaN ]
2047
2048
///
2048
2049
/// The `isTotallyOrdered(belowOrEqualTo:)` method implements the total order
2049
2050
/// relation as defined by the [IEEE 754 specification][spec].
2050
2051
///
2051
2052
/// [spec]: http://ieeexplore.ieee.org/servlet/opac?punumber=4610933
2052
2053
///
2053
2054
/// - Parameter other: A floating-point value to compare to this value.
2054
- /// - Returns: `true` if this value is ordered below `other` in a total
2055
- /// ordering of the floating-point type; otherwise, `false`.
2055
+ /// - Returns: `true` if this value is ordered below or the same as `other`
2056
+ /// in a total ordering of the floating-point type; otherwise, `false`.
2056
2057
public func isTotallyOrdered( belowOrEqualTo other: Self ) -> Bool {
2057
2058
// Quick return when possible.
2058
2059
if self < other { return true }
0 commit comments