[−][src]Trait almost::AlmostEqual
A trait for comparing floating point numbers. Not broadly intended to be used by most code (instead, use the functions at the crate root), however it could be useful for generic code too.
Associated Constants
const DEFAULT_TOLERANCE: Self
The default tolerance value for this type. Typically equivalent to
T::EPSILON.sqrt()
, as we assume that around half of the precision bits
of any arbitrary computation have been rounded away.
const MACHINE_EPSILON: Self
The machine epsilon for this type. This generally should not be used as a tolerance value (it's frequently too strict), however it can be useful when computing tolerances.
Required methods
fn almost_equals_with_tolerance(self, rhs: Self, tol: Self) -> bool
Equivalent to almost::equal_with_tolerance
.
const MY_TOLERANCE: f32 = almost::F32_TOLERANCE / 2.0; assert!(a.almost_equals_with_tolerance(b, MY_TOLERANCE));
fn almost_zero_with_tolerance(self, tol: Self) -> bool
Equivalent to almost::zero_with_tolerance
.
assert!(0.01.almost_zero_with_tolerance(0.05));
Provided methods
fn almost_zero(self) -> bool where
Self: Sized,
Self: Sized,
Equivalent to almost::zero
.
assert!(v.almost_zero());
fn almost_equals(self, rhs: Self) -> bool where
Self: Sized,
Self: Sized,
Equivalent to almost::equal
.
assert!(a.almost_equals(b));
Implementors
impl AlmostEqual for f32
[src]
const MACHINE_EPSILON: Self
[src]
const DEFAULT_TOLERANCE: Self
[src]
fn almost_equals_with_tolerance(self, rhs: Self, tol: Self) -> bool
[src]
fn almost_zero_with_tolerance(self, tol: Self) -> bool
[src]
fn almost_zero(self) -> bool where
Self: Sized,
[src]
Self: Sized,
fn almost_equals(self, rhs: Self) -> bool where
Self: Sized,
[src]
Self: Sized,
impl AlmostEqual for f64
[src]
const MACHINE_EPSILON: Self
[src]
const DEFAULT_TOLERANCE: Self
[src]
fn almost_equals_with_tolerance(self, rhs: Self, tol: Self) -> bool
[src]
fn almost_zero_with_tolerance(self, tol: Self) -> bool
[src]
fn almost_zero(self) -> bool where
Self: Sized,
[src]
Self: Sized,
fn almost_equals(self, rhs: Self) -> bool where
Self: Sized,
[src]
Self: Sized,