[][src]Macro float_eq::float_eq

macro_rules! float_eq {
    ($a:expr, $b:expr, $($eq:ident <= $max_diff:expr),+) => { ... };
    ($a:expr, $b:expr, $($eq:ident <= $max_diff:expr),+,) => { ... };
}

Checks whether two floating point expressions are equal to each other (using FloatEq).

Comparisons are applied in order from left to right, shortcutting to return early if a positive result is found.

Examples

let a: f32 = 4.;
let b: f32 = 4.0000025;

assert!( float_eq!(a, 3.9999998, rel <= f32::EPSILON) );
assert!( float_eq!(a - b, 0., abs <= 0.00001, rel <= f32::EPSILON) );
assert!( float_eq!(a - b, 0., abs <= 0.00001, ulps <= 10) );