[−][src]Struct float_cmp::F32Margin
This type defines a margin within two f32
values might be considered equal,
and is intended as the associated type for the ApproxEq
trait.
Two tests are used to determine approximate equality.
The first test considers two values approximately equal if they differ by <=
epsilon
. This will only succeed for very small numbers. Note that it may
succeed even if the parameters are of differing signs, straddling zero.
The second test considers how many ULPs (units of least precision, units in
the last place, which is the integer number of floating-point representations
that the parameters are separated by) different the parameters are and considers
them approximately equal if this is <= ulps
. For large floating-point numbers,
an ULP can be a rather large gap, but this kind of comparison is necessary
because floating-point operations must round to the nearest representable value
and so larger floating-point values accumulate larger errors.
Fields
epsilon: f32
ulps: i32
Methods
impl F32Margin
[src]
pub fn zero() -> F32Margin
[src]
pub fn epsilon(self, epsilon: f32) -> Self
[src]
pub fn ulps(self, ulps: i32) -> Self
[src]
Trait Implementations
impl Clone for F32Margin
[src]
fn clone(&self) -> F32Margin
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for F32Margin
[src]
impl Debug for F32Margin
[src]
impl Default for F32Margin
[src]
impl From<(f32, i32)> for F32Margin
[src]
Auto Trait Implementations
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,