[−][src]Macro float_eq::float_eq
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.
abs <= max_diff
is an absolute epsilon comparison.rel <= max_diff
is a relative epsilon comparison.ulps <= max_diff
is an ULPs comparison.
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) );