Trait float_cmp::ApproxEq
[−]
[src]
pub trait ApproxEq { type Flt: Ulps; fn approx_eq(
&self,
other: &Self,
epsilon: Self::Flt,
ulps: <Self::Flt as Ulps>::U
) -> bool; fn approx_ne(
&self,
other: &Self,
epsilon: Self::Flt,
ulps: <Self::Flt as Ulps>::U
) -> bool { ... } }
ApproxEq is a trait for approximate equality comparisons. The associated type Flt is a floating point type which implements Ulps, and is required so that this trait can be implemented for compound types (e.g. vectors),/ not just for the floats themselves.
Associated Types
Required Methods
fn approx_eq(
&self,
other: &Self,
epsilon: Self::Flt,
ulps: <Self::Flt as Ulps>::U
) -> bool
&self,
other: &Self,
epsilon: Self::Flt,
ulps: <Self::Flt as Ulps>::U
) -> bool
This method tests for self
and other
values to be approximately equal
using two methods: epsilon and ulps. If the values differ by less than the
given epsilon, they will be considered equal. If the values differ by more
than epsilon, but by less than the given ulps, they will also be considered
equal. Otherwise they are unequal.
Note that very small values of differing signs may pass as equal under the epsilon method. The epsilon method is very useful for these cases and for handling zeroes. The ulps method helps for larger numbers where the spacing between floating point representations gets larger.
Provided Methods
fn approx_ne(
&self,
other: &Self,
epsilon: Self::Flt,
ulps: <Self::Flt as Ulps>::U
) -> bool
&self,
other: &Self,
epsilon: Self::Flt,
ulps: <Self::Flt as Ulps>::U
) -> bool
This method tests for self
and other
values to be not approximately equal
using two methods: epsilon and ulps. If the values differ by less than the
given epsilon, they will be considered equal. If the values differ by more
than epsilon, but by less than the given ulps, they will also be considered
equal. Otherwise they are unequal.
Note that very small values of differing signs may pass as equal under the epsilon method. The epsilon method is very useful for these cases and for handling zeroes. The ulps method helps for larger numbers where the spacing between floating point representations gets larger.