diff options
| author | Pyry Kontio <pyry.kontio@drasa.eu> | 2022-03-31 17:59:36 +0900 |
|---|---|---|
| committer | Pyry Kontio <pyry.kontio@drasa.eu> | 2022-03-31 17:59:36 +0900 |
| commit | 57eec0ce13951bdd124e5c896f82fa2b74b9d913 (patch) | |
| tree | 6b22e529966afae5a0f7634077bef4887be8be14 | |
| parent | 4ee8b64a81b2e518d24f2e8acd2dfeebc686dd5d (diff) | |
| download | rust-57eec0ce13951bdd124e5c896f82fa2b74b9d913.tar.gz rust-57eec0ce13951bdd124e5c896f82fa2b74b9d913.zip | |
Re-introduce "propagating NaN" to `maximum`/`minimum`, add "ignoring NaN" to `max`/`min`, add disclaimer about the "propagation".
| -rw-r--r-- | library/core/src/num/f32.rs | 14 | ||||
| -rw-r--r-- | library/core/src/num/f64.rs | 14 |
2 files changed, 20 insertions, 8 deletions
diff --git a/library/core/src/num/f32.rs b/library/core/src/num/f32.rs index b408b5d3d5d..e3d40b58a38 100644 --- a/library/core/src/num/f32.rs +++ b/library/core/src/num/f32.rs @@ -689,7 +689,7 @@ impl f32 { self * (value / 180.0f32) } - /// Returns the maximum of the two numbers. + /// Returns the maximum of the two numbers, ignoring NaN. /// /// If one of the arguments is NaN, then the other argument is returned. /// This follows the IEEE-754 2008 semantics for maxNum, except for handling of signaling NaNs; @@ -709,7 +709,7 @@ impl f32 { intrinsics::maxnumf32(self, other) } - /// Returns the minimum of the two numbers. + /// Returns the minimum of the two numbers, ignoring NaN. /// /// If one of the arguments is NaN, then the other argument is returned. /// This follows the IEEE-754 2008 semantics for minNum, except for handling of signaling NaNs; @@ -729,7 +729,7 @@ impl f32 { intrinsics::minnumf32(self, other) } - /// Returns the maximum of the two numbers. + /// Returns the maximum of the two numbers, propagating NaN. /// /// This returns NaN when *either* argument is NaN, as opposed to /// [`f32::max`] which only returns NaN when *both* arguments are NaN. @@ -746,6 +746,9 @@ impl f32 { /// If one of the arguments is NaN, then NaN is returned. Otherwise this returns the greater /// of the two numbers. For this operation, -0.0 is considered to be less than +0.0. /// Note that this follows the semantics specified in IEEE 754-2019. + /// + /// Also note that "propagation" of NaNs here doesn't mean that the bitpattern of a NaN operand + /// is necessarily conserved; see [explanation of NaN as a special value](f32) for more info. #[must_use = "this returns the result of the comparison, without modifying either input"] #[unstable(feature = "float_minimum_maximum", issue = "91079")] #[inline] @@ -761,7 +764,7 @@ impl f32 { } } - /// Returns the minimum of the two numbers. + /// Returns the minimum of the two numbers, propagating NaN. /// /// This returns NaN when *either* argument is NaN, as opposed to /// [`f32::min`] which only returns NaN when *both* arguments are NaN. @@ -778,6 +781,9 @@ impl f32 { /// If one of the arguments is NaN, then NaN is returned. Otherwise this returns the lesser /// of the two numbers. For this operation, -0.0 is considered to be less than +0.0. /// Note that this follows the semantics specified in IEEE 754-2019. + /// + /// Also note that "propagation" of NaNs here doesn't mean that the bitpattern of a NaN operand + /// is necessarily conserved; see [explanation of NaN as a special value](f32) for more info. #[must_use = "this returns the result of the comparison, without modifying either input"] #[unstable(feature = "float_minimum_maximum", issue = "91079")] #[inline] diff --git a/library/core/src/num/f64.rs b/library/core/src/num/f64.rs index db396122651..51ccf7e8554 100644 --- a/library/core/src/num/f64.rs +++ b/library/core/src/num/f64.rs @@ -705,7 +705,7 @@ impl f64 { self * (value / 180.0) } - /// Returns the maximum of the two numbers. + /// Returns the maximum of the two numbers, ignoring NaN. /// /// If one of the arguments is NaN, then the other argument is returned. /// This follows the IEEE-754 2008 semantics for maxNum, except for handling of signaling NaNs; @@ -725,7 +725,7 @@ impl f64 { intrinsics::maxnumf64(self, other) } - /// Returns the minimum of the two numbers. + /// Returns the minimum of the two numbers, ignoring NaN. /// /// If one of the arguments is NaN, then the other argument is returned. /// This follows the IEEE-754 2008 semantics for minNum, except for handling of signaling NaNs; @@ -745,7 +745,7 @@ impl f64 { intrinsics::minnumf64(self, other) } - /// Returns the maximum of the two numbers. + /// Returns the maximum of the two numbers, propagating NaN. /// /// This returns NaN when *either* argument is NaN, as opposed to /// [`f64::max`] which only returns NaN when *both* arguments are NaN. @@ -762,6 +762,9 @@ impl f64 { /// If one of the arguments is NaN, then NaN is returned. Otherwise this returns the greater /// of the two numbers. For this operation, -0.0 is considered to be less than +0.0. /// Note that this follows the semantics specified in IEEE 754-2019. + /// + /// Also note that "propagation" of NaNs here doesn't mean that the bitpattern of a NaN operand + /// is necessarily conserved; see [explanation of NaN as a special value](f32) for more info. #[must_use = "this returns the result of the comparison, without modifying either input"] #[unstable(feature = "float_minimum_maximum", issue = "91079")] #[inline] @@ -777,7 +780,7 @@ impl f64 { } } - /// Returns the minimum of the two numbers. + /// Returns the minimum of the two numbers, propagating NaN. /// /// This returns NaN when *either* argument is NaN, as opposed to /// [`f64::min`] which only returns NaN when *both* arguments are NaN. @@ -794,6 +797,9 @@ impl f64 { /// If one of the arguments is NaN, then NaN is returned. Otherwise this returns the lesser /// of the two numbers. For this operation, -0.0 is considered to be less than +0.0. /// Note that this follows the semantics specified in IEEE 754-2019. + /// + /// Also note that "propagation" of NaNs here doesn't mean that the bitpattern of a NaN operand + /// is necessarily conserved; see [explanation of NaN as a special value](f32) for more info. #[must_use = "this returns the result of the comparison, without modifying either input"] #[unstable(feature = "float_minimum_maximum", issue = "91079")] #[inline] |
