pub trait Ulp {
fn ulp_diff(a: &Self, b: &Self) -> UlpComparisonResult;
}
Expand description
Floating point types for which two instances can be compared for Unit in the Last Place (ULP) difference.
Implementing this trait enables the usage of the ulp
comparator in
assert_matrix_eq! for the given type.
The definition here leverages the fact that for two adjacent floating point numbers, their integer representations are also adjacent.
A somewhat accessible (but not exhaustive) guide on the topic is available in the popular article [Comparing Floating Point Numbers, 2012 Edition] (https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/).
Implementations for f32
and f64
are already available, and so users should not normally
need to implement this. In the case when a custom implementation is necessary,
please see the possible return values for UlpComparisonResult.
Otherwise, we can recommend to read the source code of the included f32
and f64
implementations.
Required Methods
sourcefn ulp_diff(a: &Self, b: &Self) -> UlpComparisonResult
fn ulp_diff(a: &Self, b: &Self) -> UlpComparisonResult
Returns the difference between two floating point numbers, measured in ULP.