pub fn approx_eq(a: f32, b: f32, e: f32) -> bool
Expand description
Checks if two f32
values a
and b
are within e
of each other.
This is useful for comparing floating point values, while allowing for some rounding errors.
ยงExamples
assert_eq!(approx_eq(1.0, 1.01, 0.1), true);
assert_eq!(approx_eq(1.0, 1.3, 0.1), false);