summaryrefslogtreecommitdiffstats
path: root/vendor/libm-0.1.4/src/math/fminf.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:50 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:50 +0000
commit9835e2ae736235810b4ea1c162ca5e65c547e770 (patch)
tree3fcebf40ed70e581d776a8a4c65923e8ec20e026 /vendor/libm-0.1.4/src/math/fminf.rs
parentReleasing progress-linux version 1.70.0+dfsg2-1~progress7.99u1. (diff)
downloadrustc-9835e2ae736235810b4ea1c162ca5e65c547e770.tar.xz
rustc-9835e2ae736235810b4ea1c162ca5e65c547e770.zip
Merging upstream version 1.71.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/libm-0.1.4/src/math/fminf.rs')
-rw-r--r--vendor/libm-0.1.4/src/math/fminf.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/vendor/libm-0.1.4/src/math/fminf.rs b/vendor/libm-0.1.4/src/math/fminf.rs
new file mode 100644
index 000000000..43ec97cb5
--- /dev/null
+++ b/vendor/libm-0.1.4/src/math/fminf.rs
@@ -0,0 +1,13 @@
+#[inline]
+#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
+pub fn fminf(x: f32, y: f32) -> f32 {
+ // IEEE754 says: minNum(x, y) is the canonicalized number x if x < y, y if y < x, the
+ // canonicalized number if one operand is a number and the other a quiet NaN. Otherwise it
+ // is either x or y, canonicalized (this means results might differ among implementations).
+ // When either x or y is a signalingNaN, then the result is according to 6.2.
+ //
+ // Since we do not support sNaN in Rust yet, we do not need to handle them.
+ // FIXME(nagisa): due to https://bugs.llvm.org/show_bug.cgi?id=33303 we canonicalize by
+ // multiplying by 1.0. Should switch to the `canonicalize` when it works.
+ (if y.is_nan() || x < y { x } else { y }) * 1.0
+}