Macro float_eq::float_eq[][src]

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

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

See the top level documentation for a list of available comparison algorithms.

Examples

let a: f32 = 4.0;
let b: f32 = 4.000_002_5;

assert!(float_eq!(a, b, ulps <= 10));
assert!(float_eq!(a, 3.999_999_6, rmax <= 2.0 * f32::EPSILON));
assert!(float_eq!(a - b, 0.0, abs <= 0.000_01));