Skip to content

Commit bc93729

Browse files
committed
f*::min/max: fix comparing with libm and IEEE operations
1 parent a463b0e commit bc93729

File tree

5 files changed

+32
-40
lines changed

5 files changed

+32
-40
lines changed

library/core/src/intrinsics/mod.rs

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2949,8 +2949,7 @@ pub const unsafe fn write_bytes<T>(dst: *mut T, val: u8, count: usize);
29492949

29502950
/// Returns the minimum of two `f16` values, ignoring NaN.
29512951
///
2952-
/// This behaves like IEEE 754-2008 minNum. In particular:
2953-
/// If one of the arguments is NaN, then the other argument is returned. If the inputs compare equal
2952+
/// If one of the arguments is NaN (quiet or signaling), then the other argument is returned. If the inputs compare equal
29542953
/// (such as for the case of `+0.0` and `-0.0`), either input may be returned non-deterministically.
29552954
///
29562955
/// Note that, unlike most intrinsics, this is safe to call;
@@ -2965,8 +2964,7 @@ pub const fn minnumf16(x: f16, y: f16) -> f16;
29652964

29662965
/// Returns the minimum of two `f32` values, ignoring NaN.
29672966
///
2968-
/// This behaves like IEEE 754-2008 minNum. In particular:
2969-
/// If one of the arguments is NaN, then the other argument is returned. If the inputs compare equal
2967+
/// If one of the arguments is NaN (quiet or signaling), then the other argument is returned. If the inputs compare equal
29702968
/// (such as for the case of `+0.0` and `-0.0`), either input may be returned non-deterministically.
29712969
///
29722970
/// Note that, unlike most intrinsics, this is safe to call;
@@ -2982,8 +2980,7 @@ pub const fn minnumf32(x: f32, y: f32) -> f32;
29822980

29832981
/// Returns the minimum of two `f64` values, ignoring NaN.
29842982
///
2985-
/// This behaves like IEEE 754-2008 minNum. In particular:
2986-
/// If one of the arguments is NaN, then the other argument is returned. If the inputs compare equal
2983+
/// If one of the arguments is NaN (quiet or signaling), then the other argument is returned. If the inputs compare equal
29872984
/// (such as for the case of `+0.0` and `-0.0`), either input may be returned non-deterministically.
29882985
///
29892986
/// Note that, unlike most intrinsics, this is safe to call;
@@ -2999,8 +2996,7 @@ pub const fn minnumf64(x: f64, y: f64) -> f64;
29992996

30002997
/// Returns the minimum of two `f128` values, ignoring NaN.
30012998
///
3002-
/// This behaves like IEEE 754-2008 minNum. In particular:
3003-
/// If one of the arguments is NaN, then the other argument is returned. If the inputs compare equal
2999+
/// If one of the arguments is NaN (quiet or signaling), then the other argument is returned. If the inputs compare equal
30043000
/// (such as for the case of `+0.0` and `-0.0`), either input may be returned non-deterministically.
30053001
///
30063002
/// Note that, unlike most intrinsics, this is safe to call;
@@ -3115,8 +3111,7 @@ pub const fn minimumf128(x: f128, y: f128) -> f128 {
31153111

31163112
/// Returns the maximum of two `f16` values, ignoring NaN.
31173113
///
3118-
/// This behaves like IEEE 754-2008 maxNum. In particular:
3119-
/// If one of the arguments is NaN, then the other argument is returned. If the inputs compare equal
3114+
/// If one of the arguments is NaN (quiet or signaling), then the other argument is returned. If the inputs compare equal
31203115
/// (such as for the case of `+0.0` and `-0.0`), either input may be returned non-deterministically.
31213116
///
31223117
/// Note that, unlike most intrinsics, this is safe to call;
@@ -3131,8 +3126,7 @@ pub const fn maxnumf16(x: f16, y: f16) -> f16;
31313126

31323127
/// Returns the maximum of two `f32` values, ignoring NaN.
31333128
///
3134-
/// This behaves like IEEE 754-2008 maxNum. In particular:
3135-
/// If one of the arguments is NaN, then the other argument is returned. If the inputs compare equal
3129+
/// If one of the arguments is NaN (quiet or signaling), then the other argument is returned. If the inputs compare equal
31363130
/// (such as for the case of `+0.0` and `-0.0`), either input may be returned non-deterministically.
31373131
///
31383132
/// Note that, unlike most intrinsics, this is safe to call;
@@ -3148,8 +3142,7 @@ pub const fn maxnumf32(x: f32, y: f32) -> f32;
31483142

31493143
/// Returns the maximum of two `f64` values, ignoring NaN.
31503144
///
3151-
/// This behaves like IEEE 754-2008 maxNum. In particular:
3152-
/// If one of the arguments is NaN, then the other argument is returned. If the inputs compare equal
3145+
/// If one of the arguments is NaN (quiet or signaling), then the other argument is returned. If the inputs compare equal
31533146
/// (such as for the case of `+0.0` and `-0.0`), either input may be returned non-deterministically.
31543147
///
31553148
/// Note that, unlike most intrinsics, this is safe to call;
@@ -3165,8 +3158,7 @@ pub const fn maxnumf64(x: f64, y: f64) -> f64;
31653158

31663159
/// Returns the maximum of two `f128` values, ignoring NaN.
31673160
///
3168-
/// This behaves like IEEE 754-2008 maxNum. In particular:
3169-
/// If one of the arguments is NaN, then the other argument is returned. If the inputs compare equal
3161+
/// If one of the arguments is NaN (quiet or signaling), then the other argument is returned. If the inputs compare equal
31703162
/// (such as for the case of `+0.0` and `-0.0`), either input may be returned non-deterministically.
31713163
///
31723164
/// Note that, unlike most intrinsics, this is safe to call;

library/core/src/num/f128.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -699,9 +699,9 @@ impl f128 {
699699
/// [rules for arithmetic operations](f32#nan-bit-patterns). If the inputs compare equal (such
700700
/// as for the case of `+0.0` and `-0.0`), either input may be returned non-deterministically.
701701
///
702-
/// This follows the IEEE 754-2008 semantics for `maxNum`, except for handling of signaling NaNs;
703-
/// this function handles all NaNs the same way and avoids `maxNum`'s problems with associativity.
704-
/// This also matches the behavior of libm’s `fmax`.
702+
/// The handling of NaNs follows the IEEE 754-2019 semantics for `maximumNumber`, treating all
703+
/// NaNs the same way to ensure the operation is associative. The handling of signed zeros
704+
/// follows the IEEE 754-2008 semantics for `maxNum`.
705705
///
706706
/// ```
707707
/// #![feature(f128)]
@@ -730,9 +730,9 @@ impl f128 {
730730
/// [rules for arithmetic operations](f32#nan-bit-patterns). If the inputs compare equal (such
731731
/// as for the case of `+0.0` and `-0.0`), either input may be returned non-deterministically.
732732
///
733-
/// This follows the IEEE 754-2008 semantics for `minNum`, except for handling of signaling NaNs;
734-
/// this function handles all NaNs the same way and avoids `minNum`'s problems with associativity.
735-
/// This also matches the behavior of libm’s `fmin`.
733+
/// The handling of NaNs follows the IEEE 754-2019 semantics for `minimumNumber`, treating all
734+
/// NaNs the same way to ensure the operation is associative. The handling of signed zeros
735+
/// follows the IEEE 754-2008 semantics for `minNum`.
736736
///
737737
/// ```
738738
/// #![feature(f128)]

library/core/src/num/f16.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -692,9 +692,9 @@ impl f16 {
692692
/// [rules for arithmetic operations](f32#nan-bit-patterns). If the inputs compare equal (such
693693
/// as for the case of `+0.0` and `-0.0`), either input may be returned non-deterministically.
694694
///
695-
/// This follows the IEEE 754-2008 semantics for `maxNum`, except for handling of signaling NaNs;
696-
/// this function handles all NaNs the same way and avoids `maxNum`'s problems with associativity.
697-
/// This also matches the behavior of libm’s `fmax`.
695+
/// The handling of NaNs follows the IEEE 754-2019 semantics for `maximumNumber`, treating all
696+
/// NaNs the same way to ensure the operation is associative. The handling of signed zeros
697+
/// follows the IEEE 754-2008 semantics for `maxNum`.
698698
///
699699
/// ```
700700
/// #![feature(f16)]
@@ -722,9 +722,9 @@ impl f16 {
722722
/// [rules for arithmetic operations](f32#nan-bit-patterns). If the inputs compare equal (such
723723
/// as for the case of `+0.0` and `-0.0`), either input may be returned non-deterministically.
724724
///
725-
/// This follows the IEEE 754-2008 semantics for `minNum`, except for handling of signaling NaNs;
726-
/// this function handles all NaNs the same way and avoids `minNum`'s problems with associativity.
727-
/// This also matches the behavior of libm’s `fmin`.
725+
/// The handling of NaNs follows the IEEE 754-2019 semantics for `minimumNumber`, treating all
726+
/// NaNs the same way to ensure the operation is associative. The handling of signed zeros
727+
/// follows the IEEE 754-2008 semantics for `minNum`.
728728
///
729729
/// ```
730730
/// #![feature(f16)]

library/core/src/num/f32.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -902,9 +902,9 @@ impl f32 {
902902
/// [rules for arithmetic operations](f32#nan-bit-patterns). If the inputs compare equal (such
903903
/// as for the case of `+0.0` and `-0.0`), either input may be returned non-deterministically.
904904
///
905-
/// This follows the IEEE 754-2008 semantics for `maxNum`, except for handling of signaling NaNs;
906-
/// this function handles all NaNs the same way and avoids `maxNum`'s problems with associativity.
907-
/// This also matches the behavior of libm’s `fmax`.
905+
/// The handling of NaNs follows the IEEE 754-2019 semantics for `maximumNumber`, treating all
906+
/// NaNs the same way to ensure the operation is associative. The handling of signed zeros
907+
/// follows the IEEE 754-2008 semantics for `maxNum`.
908908
///
909909
/// ```
910910
/// let x = 1.0f32;
@@ -928,9 +928,9 @@ impl f32 {
928928
/// [rules for arithmetic operations](f32#nan-bit-patterns). If the inputs compare equal (such
929929
/// as for the case of `+0.0` and `-0.0`), either input may be returned non-deterministically.
930930
///
931-
/// This follows the IEEE 754-2008 semantics for `minNum`, except for handling of signaling NaNs;
932-
/// this function handles all NaNs the same way and avoids `minNum`'s problems with associativity.
933-
/// This also matches the behavior of libm’s `fmin`.
931+
/// The handling of NaNs follows the IEEE 754-2019 semantics for `minimumNumber`, treating all
932+
/// NaNs the same way to ensure the operation is associative. The handling of signed zeros
933+
/// follows the IEEE 754-2008 semantics for `minNum`.
934934
///
935935
/// ```
936936
/// let x = 1.0f32;

library/core/src/num/f64.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -920,9 +920,9 @@ impl f64 {
920920
/// [rules for arithmetic operations](f32#nan-bit-patterns). If the inputs compare equal (such
921921
/// as for the case of `+0.0` and `-0.0`), either input may be returned non-deterministically.
922922
///
923-
/// This follows the IEEE 754-2008 semantics for `maxNum`, except for handling of signaling NaNs;
924-
/// this function handles all NaNs the same way and avoids `maxNum`'s problems with associativity.
925-
/// This also matches the behavior of libm’s `fmax`.
923+
/// The handling of NaNs follows the IEEE 754-2019 semantics for `maximumNumber`, treating all
924+
/// NaNs the same way to ensure the operation is associative. The handling of signed zeros
925+
/// follows the IEEE 754-2008 semantics for `maxNum`.
926926
///
927927
/// ```
928928
/// let x = 1.0_f64;
@@ -946,9 +946,9 @@ impl f64 {
946946
/// [rules for arithmetic operations](f32#nan-bit-patterns). If the inputs compare equal (such
947947
/// as for the case of `+0.0` and `-0.0`), either input may be returned non-deterministically.
948948
///
949-
/// This follows the IEEE 754-2008 semantics for `minNum`, except for handling of signaling NaNs;
950-
/// this function handles all NaNs the same way and avoids `minNum`'s problems with associativity.
951-
/// This also matches the behavior of libm’s `fmin`.
949+
/// The handling of NaNs follows the IEEE 754-2019 semantics for `minimumNumber`, treating all
950+
/// NaNs the same way to ensure the operation is associative. The handling of signed zeros
951+
/// follows the IEEE 754-2008 semantics for `minNum`.
952952
///
953953
/// ```
954954
/// let x = 1.0_f64;

0 commit comments

Comments
 (0)