Macro assert_eq_f32

Source
macro_rules! assert_eq_f32 {
    ($a:expr, $b:expr $(,)?) => { ... };
    ($a:expr, $b:expr, $($message:tt)+) => { ... };
}
Expand description

Assert two floating point numbers are equal within 2.0 * f32::EPSILON.

Pseudocode:
a = b

  • If true, return ().

  • Otherwise, call panic! with a message and the values of the expressions with their debug representations.

§Examples

use assertables::*;

let a: f32 = 0.3333333;
let b: f32 = 0.3333333;
assert_eq_f32!(a, b);

// This will panic
let a: f32 = 0.3333333;
let b: f32 = 0.3333336;
assert_eq_f32!(a, b);
// assertion failed: `assert_eq_f32!(a, b)`
// https://docs.rs/assertables/9.7.0/assertables/macro.assert_eq_f32.html
//  a label: `a`,
//  a debug: `0.3333333`,
//  b label: `b`,
//  b debug: `0.3333336`,`
//  Δ: `0.00000029802322`,
//  ε: `0.00000023841858`

§Module macros