| 1 |
/* SPDX-License-Identifier: MIT OR Apache-2.0 */ |
| 2 |
//! IEEE 754-2011 `maxNum`. This has been superseded by IEEE 754-2019 `maximumNumber`. |
| 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 fmax<F: Float>(x: F, y: F) -> F { |
| 21 |
let res = if x.is_nan() || x < y { y } else { x }; |
| 22 |
res.canonicalize() |
| 23 |
} |