1use core::f64;
2
3/// Positive difference (f64)
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)]
12pub fn fdim(x: f64, y: f64) -> f64 {
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