Macro float_eq::debug_assert_float_eq
source · [−]macro_rules! debug_assert_float_eq {
($($arg:tt)*) => { ... };
}
Expand description
Asserts that two floating point expressions are equal to each other.
See the top level documentation for a list of available comparison algorithms.
On panic, this macro will print the values of the expressions with their debug
representations, with additional information from the comparison operations.
Like assert!
, this macro has a second form, where a custom panic message can
be provided.
Unlike assert_float_eq!
, debug_assert_float_eq!
statements are only enabled in
non optimized builds by default. See debug_assert_eq!
for more details.
Examples
let a: f32 = 4.0;
let b: f32 = 4.000_002_5;
debug_assert_float_eq!(a, b, ulps <= 10);
debug_assert_float_eq!(a, 3.999_999_6, rmax <= 2.0 * f32::EPSILON);
debug_assert_float_eq!(a - b, 0.0, abs <= 0.000_01, "Checking that {} == {}", a, b);