]> git.proxmox.com Git - rustc.git/blame - vendor/compiler_builtins/libm/src/math/fdimf.rs
New upstream version 1.41.1+dfsg1
[rustc.git] / vendor / compiler_builtins / libm / src / math / fdimf.rs
CommitLineData
8faf50e0
XL
1use core::f32;
2
dc9dc135
XL
3/// Positive difference (f32)
4///
5/// Determines the positive difference between arguments, returning:
6/// * x - y if x > y, or
7/// * +0 if x <= y, or
8/// * NAN if either argument is NAN.
9///
10/// A range error may occur.
48663c56 11#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
8faf50e0
XL
12pub fn fdimf(x: f32, y: f32) -> f32 {
13 if x.is_nan() {
14 x
15 } else if y.is_nan() {
16 y
48663c56
XL
17 } else if x > y {
18 x - y
8faf50e0 19 } else {
48663c56 20 0.0
8faf50e0
XL
21 }
22}