[−][src]Function almost::equal_with_tolerance
pub fn equal_with_tolerance<T: AlmostEqual>(
lhs: T,
rhs: T,
tolerance: T
) -> bool
Returns true
if lhs
and rhs
are almost equal using the provided
relative tolerance.
const MY_TOLERANCE: f32 = almost::F32_TOLERANCE / 2.0; assert!(almost::equal_with_tolerance(0.1 + 0.2, 0.3, MY_TOLERANCE));
Do not use this to compare a value with a constant zero. Instead, for this
you should use almost::zero_with_tolerance
.
Panics
This function panics in debug mode if tolerance
is less than T::EPSILON
or greater than 1.0, as the results are unlikely to be sensible.
In release builds it should never panic.