]> git.proxmox.com Git - rustc.git/blob - vendor/libm-0.1.4/src/math/fdimf.rs
New upstream version 1.74.1+dfsg1
[rustc.git] / vendor / libm-0.1.4 / src / math / fdimf.rs
1 use core::f32;
2
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.
11 #[inline]
12 #[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
13 pub fn fdimf(x: f32, y: f32) -> f32 {
14 if x.is_nan() {
15 x
16 } else if y.is_nan() {
17 y
18 } else if x > y {
19 x - y
20 } else {
21 0.0
22 }
23 }