Skip to main content

almost_eq_rel

Function almost_eq_rel 

Source
pub fn almost_eq_rel<T: Real>(a: T, b: T, tol: T) -> bool
Expand description

Relative-tolerance equality: |a - b| <= tol * max(|a|, |b|). Equal when both are zero.

ยงExamples

use mathverse_core::precision::almost_eq_rel;

assert!(almost_eq_rel(1e15, 1e15 + 1.0, 1e-12));
assert!(almost_eq_rel(0.0, 0.0, 1e-10));