Skip to content

Commit 3287178

Browse files
committed
float::min/max: reference NaN bit pattern rules
1 parent 3ff30e7 commit 3287178

File tree

4 files changed

+48
-24
lines changed

4 files changed

+48
-24
lines changed

library/core/src/num/f128.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -694,11 +694,14 @@ impl f128 {
694694

695695
/// Returns the maximum of the two numbers, ignoring NaN.
696696
///
697-
/// If one of the arguments is NaN, then the other argument is returned.
697+
/// If exactly one of the arguments is NaN, then the other argument is returned. If both
698+
/// arguments are NaN, the return value is NaN, with the bit pattern picked using the usual
699+
/// [rules for arithmetic operations](f32#nan-bit-patterns). If the inputs compare equal (such
700+
/// as for the case of `+0.0` and `-0.0`), either input may be returned non-deterministically.
701+
///
698702
/// This follows the IEEE 754-2008 semantics for `maxNum`, except for handling of signaling NaNs;
699703
/// this function handles all NaNs the same way and avoids `maxNum`'s problems with associativity.
700-
/// This also matches the behavior of libm’s fmax. In particular, if the inputs compare equal
701-
/// (such as for the case of `+0.0` and `-0.0`), either input may be returned non-deterministically.
704+
/// This also matches the behavior of libm’s `fmax`.
702705
///
703706
/// ```
704707
/// #![feature(f128)]
@@ -722,11 +725,14 @@ impl f128 {
722725

723726
/// Returns the minimum of the two numbers, ignoring NaN.
724727
///
725-
/// If one of the arguments is NaN, then the other argument is returned.
728+
/// If exactly one of the arguments is NaN, then the other argument is returned. If both
729+
/// arguments are NaN, the return value is NaN, with the bit pattern picked using the usual
730+
/// [rules for arithmetic operations](f32#nan-bit-patterns). If the inputs compare equal (such
731+
/// as for the case of `+0.0` and `-0.0`), either input may be returned non-deterministically.
732+
///
726733
/// This follows the IEEE 754-2008 semantics for `minNum`, except for handling of signaling NaNs;
727734
/// this function handles all NaNs the same way and avoids `minNum`'s problems with associativity.
728-
/// This also matches the behavior of libm’s fmin. In particular, if the inputs compare equal
729-
/// (such as for the case of `+0.0` and `-0.0`), either input may be returned non-deterministically.
735+
/// This also matches the behavior of libm’s `fmin`.
730736
///
731737
/// ```
732738
/// #![feature(f128)]

library/core/src/num/f16.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -687,11 +687,14 @@ impl f16 {
687687

688688
/// Returns the maximum of the two numbers, ignoring NaN.
689689
///
690-
/// If one of the arguments is NaN, then the other argument is returned.
690+
/// If exactly one of the arguments is NaN, then the other argument is returned. If both
691+
/// arguments are NaN, the return value is NaN, with the bit pattern picked using the usual
692+
/// [rules for arithmetic operations](f32#nan-bit-patterns). If the inputs compare equal (such
693+
/// as for the case of `+0.0` and `-0.0`), either input may be returned non-deterministically.
694+
///
691695
/// This follows the IEEE 754-2008 semantics for `maxNum`, except for handling of signaling NaNs;
692696
/// this function handles all NaNs the same way and avoids `maxNum`'s problems with associativity.
693-
/// This also matches the behavior of libm’s fmax. In particular, if the inputs compare equal
694-
/// (such as for the case of `+0.0` and `-0.0`), either input may be returned non-deterministically.
697+
/// This also matches the behavior of libm’s `fmax`.
695698
///
696699
/// ```
697700
/// #![feature(f16)]
@@ -714,11 +717,14 @@ impl f16 {
714717

715718
/// Returns the minimum of the two numbers, ignoring NaN.
716719
///
717-
/// If one of the arguments is NaN, then the other argument is returned.
720+
/// If exactly one of the arguments is NaN, then the other argument is returned. If both
721+
/// arguments are NaN, the return value is NaN, with the bit pattern picked using the usual
722+
/// [rules for arithmetic operations](f32#nan-bit-patterns). If the inputs compare equal (such
723+
/// as for the case of `+0.0` and `-0.0`), either input may be returned non-deterministically.
724+
///
718725
/// This follows the IEEE 754-2008 semantics for `minNum`, except for handling of signaling NaNs;
719726
/// this function handles all NaNs the same way and avoids `minNum`'s problems with associativity.
720-
/// This also matches the behavior of libm’s fmin. In particular, if the inputs compare equal
721-
/// (such as for the case of `+0.0` and `-0.0`), either input may be returned non-deterministically.
727+
/// This also matches the behavior of libm’s `fmin`.
722728
///
723729
/// ```
724730
/// #![feature(f16)]

library/core/src/num/f32.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -897,11 +897,14 @@ impl f32 {
897897

898898
/// Returns the maximum of the two numbers, ignoring NaN.
899899
///
900-
/// If one of the arguments is NaN, then the other argument is returned.
900+
/// If exactly one of the arguments is NaN, then the other argument is returned. If both
901+
/// arguments are NaN, the return value is NaN, with the bit pattern picked using the usual
902+
/// [rules for arithmetic operations](f32#nan-bit-patterns). If the inputs compare equal (such
903+
/// as for the case of `+0.0` and `-0.0`), either input may be returned non-deterministically.
904+
///
901905
/// This follows the IEEE 754-2008 semantics for `maxNum`, except for handling of signaling NaNs;
902906
/// this function handles all NaNs the same way and avoids `maxNum`'s problems with associativity.
903-
/// This also matches the behavior of libm’s fmax. In particular, if the inputs compare equal
904-
/// (such as for the case of `+0.0` and `-0.0`), either input may be returned non-deterministically.
907+
/// This also matches the behavior of libm’s `fmax`.
905908
///
906909
/// ```
907910
/// let x = 1.0f32;
@@ -920,11 +923,14 @@ impl f32 {
920923

921924
/// Returns the minimum of the two numbers, ignoring NaN.
922925
///
923-
/// If one of the arguments is NaN, then the other argument is returned.
926+
/// If exactly one of the arguments is NaN, then the other argument is returned. If both
927+
/// arguments are NaN, the return value is NaN, with the bit pattern picked using the usual
928+
/// [rules for arithmetic operations](f32#nan-bit-patterns). If the inputs compare equal (such
929+
/// as for the case of `+0.0` and `-0.0`), either input may be returned non-deterministically.
930+
///
924931
/// This follows the IEEE 754-2008 semantics for `minNum`, except for handling of signaling NaNs;
925932
/// this function handles all NaNs the same way and avoids `minNum`'s problems with associativity.
926-
/// This also matches the behavior of libm’s fmin. In particular, if the inputs compare equal
927-
/// (such as for the case of `+0.0` and `-0.0`), either input may be returned non-deterministically.
933+
/// This also matches the behavior of libm’s `fmin`.
928934
///
929935
/// ```
930936
/// let x = 1.0f32;

library/core/src/num/f64.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -915,11 +915,14 @@ impl f64 {
915915

916916
/// Returns the maximum of the two numbers, ignoring NaN.
917917
///
918-
/// If one of the arguments is NaN, then the other argument is returned.
918+
/// If exactly one of the arguments is NaN, then the other argument is returned. If both
919+
/// arguments are NaN, the return value is NaN, with the bit pattern picked using the usual
920+
/// [rules for arithmetic operations](f32#nan-bit-patterns). If the inputs compare equal (such
921+
/// as for the case of `+0.0` and `-0.0`), either input may be returned non-deterministically.
922+
///
919923
/// This follows the IEEE 754-2008 semantics for `maxNum`, except for handling of signaling NaNs;
920924
/// this function handles all NaNs the same way and avoids `maxNum`'s problems with associativity.
921-
/// This also matches the behavior of libm’s fmax. In particular, if the inputs compare equal
922-
/// (such as for the case of `+0.0` and `-0.0`), either input may be returned non-deterministically.
925+
/// This also matches the behavior of libm’s `fmax`.
923926
///
924927
/// ```
925928
/// let x = 1.0_f64;
@@ -938,11 +941,14 @@ impl f64 {
938941

939942
/// Returns the minimum of the two numbers, ignoring NaN.
940943
///
941-
/// If one of the arguments is NaN, then the other argument is returned.
944+
/// If exactly one of the arguments is NaN, then the other argument is returned. If both
945+
/// arguments are NaN, the return value is NaN, with the bit pattern picked using the usual
946+
/// [rules for arithmetic operations](f32#nan-bit-patterns). If the inputs compare equal (such
947+
/// as for the case of `+0.0` and `-0.0`), either input may be returned non-deterministically.
948+
///
942949
/// This follows the IEEE 754-2008 semantics for `minNum`, except for handling of signaling NaNs;
943950
/// this function handles all NaNs the same way and avoids `minNum`'s problems with associativity.
944-
/// This also matches the behavior of libm’s fmin. In particular, if the inputs compare equal
945-
/// (such as for the case of `+0.0` and `-0.0`), either input may be returned non-deterministically.
951+
/// This also matches the behavior of libm’s `fmin`.
946952
///
947953
/// ```
948954
/// let x = 1.0_f64;

0 commit comments

Comments
 (0)