[−][src]Trait float_eq::FloatDiff
Algorithms to compute the difference between two IEEE floating point values.
Associated Types
type AbsDiff
Type of the absolute difference between two values.
This is almost always Self.
type UlpsDiff
Type of the absolute difference between two values in terms of ULPs.
This should be an unsigned integer of the same size as the underlying
floating point type, for example f32 uses u32.
Required methods
fn abs_diff(&self, other: &Self) -> Self::AbsDiff
Always positive absolute difference between two values.
Implementations should be the equivalent of:
(self - other).abs()
fn ulps_diff(&self, other: &Self) -> Self::UlpsDiff
Always positive absolute difference between two values in terms of ULPs
Implementations should be the equivalent of (using f32 as an example):
let a = (self.to_bits()) as u32;
let b = (other.to_bits()) as u32;
let max = a.max(b);
let min = a.min(b);
max - min