mirror of
https://github.com/rust-lang/rust.git
synced 2026-06-01 14:10:03 +03:00
Re-introduce "propagating NaN" to maximum/minimum, add "ignoring NaN" to max/min, add disclaimer about the "propagation".
This commit is contained in:
@@ -689,7 +689,7 @@ pub fn to_radians(self) -> 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 @@ pub fn max(self, other: f32) -> 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 @@ pub fn min(self, other: f32) -> 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 @@ pub fn min(self, other: f32) -> 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 @@ pub fn maximum(self, other: f32) -> 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 @@ pub fn maximum(self, other: f32) -> 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]
|
||||
|
||||
@@ -705,7 +705,7 @@ pub fn to_radians(self) -> 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 @@ pub fn max(self, other: f64) -> 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 @@ pub fn min(self, other: f64) -> 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 @@ pub fn min(self, other: f64) -> 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 @@ pub fn maximum(self, other: f64) -> 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 @@ pub fn maximum(self, other: f64) -> 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]
|
||||
|
||||
Reference in New Issue
Block a user