[][src]Macro float_eq::float_ne

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

Checks if two floating point expressions are not equal to each other.

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

When comparing composite types, variants that use a uniform max_diff value across all fields are also available:

Examples

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

assert!( float_ne!(a, 3.999_999, rel <= f32::EPSILON) );
assert!( float_ne!(a - b, 0., abs <= 0.000_01, rel <= f32::EPSILON) );
assert!( float_ne!(a - b, 0., abs <= 0.000_01, ulps <= 10) );

let c = [1.000_000_2f32, -2.0];
let d = [1.0f32, -2.000_002];
assert!( float_ne!(c, d, abs_all <= 0.000_000_1, ulps <= [2, 7]) );