nearly!() { /* proc-macro */ }Expand description
Returns whether the given comparison is nearly true using the provided tolerance.
The comparison can be:
a == bfor testing whether a is nearly equal to ba != bfor testing whether a is not nearly equal to b
The tolerance used can be:
epsfor an absolute epsilon toleranceulpsfor an ulps based tolerancetolfor an absolute epsilon and ulps based tolerancedefaultfor an absolute epsilon and ulps based tolerance using default values
ยงExamples
use nearly::{nearly, Tolerance};
let a: f32 = 1.0;
let b: f32 = 1.0;
// use absolute epsilon tolerance
let eq: bool = nearly!(a == b, eps = 0.01);
// use ulps based tolerance
let eq: bool = nearly!(a == b, ulps = 5);
// use absolute epsilon and ulps based tolerance
let eq: bool = nearly!(a == b, eps = 0.01, ulps = 5);
let eq: bool = nearly!(a == b, tol = Tolerance::new(0.01, 5));
// use default absolute epsilon and default ulps based tolerance
let eq: bool = nearly!(a == b);