Debian Codegraph @

debian/rust-vendor/libm/src/math/generic/fminimum.rs

raw
1 /* SPDX-License-Identifier: MIT OR Apache-2.0 */
2 //! IEEE 754-2019 `minimum`.
3 //!
4 //! Per the spec, returns the canonicalized result of:
5 //! - `x` if `x < y`
6 //! - `y` if `y < x`
7 //! - -0.0 if x and y are zero with opposite signs
8 //! - qNaN if either operation is NaN
9 //!
10 //! Excluded from our implementation is sNaN handling.
11
12 use crate::support::Float;
13
14 #[inline]
15 pub fn fminimum<F: Float>(x: F, y: F) -> F {
16 let res = if x.is_nan() {
17 x
18 } else if y.is_nan() {
19 y
20 } else if x < y || (x.biteq(F::NEG_ZERO) && y.is_sign_positive()) {
21 x
22 } else {
23 y
24 };
25
26 res.canonicalize()
27 }