pub struct F64Margin {
pub epsilon: f64,
pub ulps: i64,
}
Expand description
This type defines a margin within two f64
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: f64
§ulps: i64
Implementations§
Trait Implementations§
impl Copy for F64Margin
Auto Trait Implementations§
impl Freeze for F64Margin
impl RefUnwindSafe for F64Margin
impl Send for F64Margin
impl Sync for F64Margin
impl Unpin for F64Margin
impl UnwindSafe for F64Margin
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)