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 | #[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] |
12 | pub fn fdimf(x: f32, y: f32) -> f32 { |
13 | if x.is_nan() { |
14 | x |
15 | } else if y.is_nan() { |
16 | y |
17 | } else if x > y { |
18 | x - y |
19 | } else { |
20 | 0.0 |
21 | } |
22 | } |
23 |