[][src]Function almost::equal_with

pub fn equal_with<T: AlmostEqual>(lhs: T, rhs: T, tolerance: T::Float) -> 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(0.1 + 0.2, 0.3f32, MY_TOLERANCE));

Do not use this to compare a value with a constant zero. Instead, for this you should use almost::zero_with.

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.