Skip to main content

almost_equals

Function almost_equals 

Source
pub fn almost_equals(a: f64, b: f64, eps: f64) -> bool
Expand description

Whether a and b are equal up to the relative tolerance eps, i.e. whether |a - b| / (|a| + |b|) < eps (with sensible handling of zeros, infinities and NaNs, see cmp_epsilon).

Binds igraph_almost_equals.

ยงExamples

use igraph::misc::almost_equals;
assert!(almost_equals(0.1 + 0.2, 0.3, 1e-12));
assert!(!almost_equals(1.0, 1.1, 1e-3));