[][src]Trait almost::AlmostEqual

pub trait AlmostEqual {
    const DEFAULT_TOLERANCE: Self;
    const MACHINE_EPSILON: Self;

    fn almost_equals_with_tolerance(self, rhs: Self, tol: Self) -> bool;
fn almost_zero_with_tolerance(self, tol: Self) -> bool; fn almost_zero(self) -> bool
    where
        Self: Sized
, { ... }
fn almost_equals(self, rhs: Self) -> bool
    where
        Self: Sized
, { ... } }

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.

Loading content...

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));
Loading content...

Provided methods

fn almost_zero(self) -> bool where
    Self: Sized

Equivalent to almost::zero.

assert!(v.almost_zero());

fn almost_equals(self, rhs: Self) -> bool where
    Self: Sized

Equivalent to almost::equal.

assert!(a.almost_equals(b));
Loading content...

Implementors

impl AlmostEqual for f32[src]

fn almost_zero(self) -> bool where
    Self: Sized
[src]

fn almost_equals(self, rhs: Self) -> bool where
    Self: Sized
[src]

impl AlmostEqual for f64[src]

fn almost_zero(self) -> bool where
    Self: Sized
[src]

fn almost_equals(self, rhs: Self) -> bool where
    Self: Sized
[src]

Loading content...