Skip to main content

almost_eq_ulp

Function almost_eq_ulp 

Source
pub fn almost_eq_ulp(a: f64, b: f64, max_ulp: i64) -> bool
Expand description

ULP-based floating-point equality for f64.

Returns true if a and b differ by at most max_ulp representable values. Handles signed zeros and infinities correctly.

ยงExamples

use mathverse_core::precision::almost_eq_ulp;

assert!(almost_eq_ulp(1.0, 1.0, 0));
assert!(almost_eq_ulp(f64::INFINITY, f64::INFINITY, 0));
assert!(!almost_eq_ulp(f64::NAN, f64::NAN, 0));