pub fn nearly_equal<T>(a: T, b: T, rel_tol: T, abs_tol: T) -> boolExpand description
Whether two floats are nearly equal (up to specified tolerance)
§Arguments
afirst floatbsecond floatrel_tolrelative tolerance (must be positive)abs_tolabsolute tolerance (must be positive)
§Results
Returns true if and only if a is nearly equal to b
In particular, this function will return true if and only if BOTH of the following conditions are satisfied
a==b, e.g., if the two floats are identical or both equal to infinity|a-b| <= max(abs_tol, rel_tol*max(|a|, |b|))
The function will return false if either of a or b is NaN.
It works with f64 and f32
§Panics
The function will panic if the specified relative or absolute tolerance is not positive.