Skip to content

Commit 57eec0c

Browse files
committed
Re-introduce "propagating NaN" to maximum/minimum, add "ignoring NaN" to max/min, add disclaimer about the "propagation".
1 parent 4ee8b64 commit 57eec0c

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

library/core/src/num/f32.rs

+10-4
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ impl f32 {
689689
self * (value / 180.0f32)
690690
}
691691

692-
/// Returns the maximum of the two numbers.
692+
/// Returns the maximum of the two numbers, ignoring NaN.
693693
///
694694
/// If one of the arguments is NaN, then the other argument is returned.
695695
/// This follows the IEEE-754 2008 semantics for maxNum, except for handling of signaling NaNs;
@@ -709,7 +709,7 @@ impl f32 {
709709
intrinsics::maxnumf32(self, other)
710710
}
711711

712-
/// Returns the minimum of the two numbers.
712+
/// Returns the minimum of the two numbers, ignoring NaN.
713713
///
714714
/// If one of the arguments is NaN, then the other argument is returned.
715715
/// This follows the IEEE-754 2008 semantics for minNum, except for handling of signaling NaNs;
@@ -729,7 +729,7 @@ impl f32 {
729729
intrinsics::minnumf32(self, other)
730730
}
731731

732-
/// Returns the maximum of the two numbers.
732+
/// Returns the maximum of the two numbers, propagating NaN.
733733
///
734734
/// This returns NaN when *either* argument is NaN, as opposed to
735735
/// [`f32::max`] which only returns NaN when *both* arguments are NaN.
@@ -746,6 +746,9 @@ impl f32 {
746746
/// If one of the arguments is NaN, then NaN is returned. Otherwise this returns the greater
747747
/// of the two numbers. For this operation, -0.0 is considered to be less than +0.0.
748748
/// Note that this follows the semantics specified in IEEE 754-2019.
749+
///
750+
/// Also note that "propagation" of NaNs here doesn't mean that the bitpattern of a NaN operand
751+
/// is necessarily conserved; see [explanation of NaN as a special value](f32) for more info.
749752
#[must_use = "this returns the result of the comparison, without modifying either input"]
750753
#[unstable(feature = "float_minimum_maximum", issue = "91079")]
751754
#[inline]
@@ -761,7 +764,7 @@ impl f32 {
761764
}
762765
}
763766

764-
/// Returns the minimum of the two numbers.
767+
/// Returns the minimum of the two numbers, propagating NaN.
765768
///
766769
/// This returns NaN when *either* argument is NaN, as opposed to
767770
/// [`f32::min`] which only returns NaN when *both* arguments are NaN.
@@ -778,6 +781,9 @@ impl f32 {
778781
/// If one of the arguments is NaN, then NaN is returned. Otherwise this returns the lesser
779782
/// of the two numbers. For this operation, -0.0 is considered to be less than +0.0.
780783
/// Note that this follows the semantics specified in IEEE 754-2019.
784+
///
785+
/// Also note that "propagation" of NaNs here doesn't mean that the bitpattern of a NaN operand
786+
/// is necessarily conserved; see [explanation of NaN as a special value](f32) for more info.
781787
#[must_use = "this returns the result of the comparison, without modifying either input"]
782788
#[unstable(feature = "float_minimum_maximum", issue = "91079")]
783789
#[inline]

library/core/src/num/f64.rs

+10-4
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,7 @@ impl f64 {
705705
self * (value / 180.0)
706706
}
707707

708-
/// Returns the maximum of the two numbers.
708+
/// Returns the maximum of the two numbers, ignoring NaN.
709709
///
710710
/// If one of the arguments is NaN, then the other argument is returned.
711711
/// This follows the IEEE-754 2008 semantics for maxNum, except for handling of signaling NaNs;
@@ -725,7 +725,7 @@ impl f64 {
725725
intrinsics::maxnumf64(self, other)
726726
}
727727

728-
/// Returns the minimum of the two numbers.
728+
/// Returns the minimum of the two numbers, ignoring NaN.
729729
///
730730
/// If one of the arguments is NaN, then the other argument is returned.
731731
/// This follows the IEEE-754 2008 semantics for minNum, except for handling of signaling NaNs;
@@ -745,7 +745,7 @@ impl f64 {
745745
intrinsics::minnumf64(self, other)
746746
}
747747

748-
/// Returns the maximum of the two numbers.
748+
/// Returns the maximum of the two numbers, propagating NaN.
749749
///
750750
/// This returns NaN when *either* argument is NaN, as opposed to
751751
/// [`f64::max`] which only returns NaN when *both* arguments are NaN.
@@ -762,6 +762,9 @@ impl f64 {
762762
/// If one of the arguments is NaN, then NaN is returned. Otherwise this returns the greater
763763
/// of the two numbers. For this operation, -0.0 is considered to be less than +0.0.
764764
/// Note that this follows the semantics specified in IEEE 754-2019.
765+
///
766+
/// Also note that "propagation" of NaNs here doesn't mean that the bitpattern of a NaN operand
767+
/// is necessarily conserved; see [explanation of NaN as a special value](f32) for more info.
765768
#[must_use = "this returns the result of the comparison, without modifying either input"]
766769
#[unstable(feature = "float_minimum_maximum", issue = "91079")]
767770
#[inline]
@@ -777,7 +780,7 @@ impl f64 {
777780
}
778781
}
779782

780-
/// Returns the minimum of the two numbers.
783+
/// Returns the minimum of the two numbers, propagating NaN.
781784
///
782785
/// This returns NaN when *either* argument is NaN, as opposed to
783786
/// [`f64::min`] which only returns NaN when *both* arguments are NaN.
@@ -794,6 +797,9 @@ impl f64 {
794797
/// If one of the arguments is NaN, then NaN is returned. Otherwise this returns the lesser
795798
/// of the two numbers. For this operation, -0.0 is considered to be less than +0.0.
796799
/// Note that this follows the semantics specified in IEEE 754-2019.
800+
///
801+
/// Also note that "propagation" of NaNs here doesn't mean that the bitpattern of a NaN operand
802+
/// is necessarily conserved; see [explanation of NaN as a special value](f32) for more info.
797803
#[must_use = "this returns the result of the comparison, without modifying either input"]
798804
#[unstable(feature = "float_minimum_maximum", issue = "91079")]
799805
#[inline]

0 commit comments

Comments
 (0)