assert_f32_far

Macro assert_f32_far 

Source
macro_rules! assert_f32_far {
    ($a:expr, $b:expr, $n:expr) => { ... };
    ($a:expr, $b:expr) => { ... };
}
Expand description

Assert two 32-bit floats are not within n steps of each other.

Panics if the two floats are less than or equal to n steps away from each other.

  • a - First float.
  • b - Second float.
  • n - Step tolerance between floats (defaults to 4).

Each step is derived from the previous float by incrementing the float’s bits, as if they were an integer, by 1. For example, the next float from 1e-45 (0x00000001) would be 3e-45 (0x00000002).

§Examples

assert_f32_far!(1e-45, 8e-45);
assert_f32_far!(1e-45, 1.4e-44, 8);
assert_f32_far!(3e37, 3.0000014e+37);