pub fn equal<T: AlmostEqual>(lhs: T, rhs: T) -> bool
Expand description
Returns true
if lhs
and rhs
are almost equal.
assert!(almost::equal(0.1 + 0.2, 0.3));
Do not use this to compare a value with a constant zero. Instead, for this
you should use almost::zero
.
This uses a relative comparison with a threshold chosen to be good for
values produced by arbitrary computation, while still tight enough for it to
be unlikely to cause false positives in practice This is a good default, but
you have a tighter bound you need to use,
almost::equal_with
is also available.
Note that this returns false in the case that both values are NaN.