[][src]Trait float_eq::FloatDiff

pub trait FloatDiff {
    type AbsDiff;
    type UlpsDiff;
    fn abs_diff(&self, other: &Self) -> Self::AbsDiff;
fn ulps_diff(&self, other: &Self) -> Self::UlpsDiff; }

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.

Loading content...

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
Loading content...

Implementations on Foreign Types

impl FloatDiff for f32[src]

type AbsDiff = f32

type UlpsDiff = u32

impl FloatDiff for f64[src]

type AbsDiff = f64

type UlpsDiff = u64

Loading content...

Implementors

Loading content...