fastmaths 0.1.0

High-performance no_std math routines targeting glibc parity and strict f64 accuracy.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
//! fdim(x,y) implementation.
//!
//! Computes max(x-y, 0) with IEEE NaN propagation rules. This is a thin helper
//! but kept for libm parity.

#[inline(always)]
pub fn fdim(x: f64, y: f64) -> f64 {
    if x.is_nan() || y.is_nan() {
        return f64::NAN;
    }
    if x > y { x - y } else { 0.0 }
}