[][src]Trait rulinalg::ulp::Ulp

pub trait Ulp {
    fn ulp_diff(a: &Self, b: &Self) -> UlpComparisonResult;

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

fn ulp_diff(a: &Self, b: &Self) -> UlpComparisonResult

Returns the difference between two floating point numbers, measured in ULP.

Loading content...


impl Ulp for f32[src]

impl Ulp for f64[src]

Loading content...