Debian Codegraph @

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

raw
1 /* SPDX-License-Identifier: MIT OR Apache-2.0 */
2 //! IEEE 754-2008 `minNum`. This has been superseded by IEEE 754-2019 `minimumNumber`.
3 //!
4 //! Per the spec, returns the canonicalized result of:
5 //! - `x` if `x < y`
6 //! - `y` if `y < x`
7 //! - The other number if one is NaN
8 //! - Otherwise, either `x` or `y`, canonicalized
9 //! - -0.0 and +0.0 may be disregarded (unlike newer operations)
10 //!
11 //! Excluded from our implementation is sNaN handling.
12 //!
13 //! More on the differences: [link].
14 //!
15 //! [link]: https://grouper.ieee.org/groups/msc/ANSI_IEEE-Std-754-2019/background/minNum_maxNum_Removal_Demotion_v3.pdf
16
17 use crate::support::Float;
18
19 #[inline]
20 pub fn fmin<F: Float>(x: F, y: F) -> F {
21 let res = if y.is_nan() || x < y { x } else { y };
22 res.canonicalize()
23 }