Skip to main content

float_eq

Macro float_eq 

Source
macro_rules! float_eq {
    ($a:expr, $b:expr $(,)?) => { ... };
}
Expand description

Compares two floats for approximate equality within epsilon tolerance.

Returns true if the absolute difference between $a and $b is less than EPSILON (0.001).

ยงExamples

assert!(float_eq!(1.0_f32, 1.0005_f32));
assert!(!float_eq!(1.0_f32, 1.01_f32));