Trait float_cmp::Ulps

source ·
pub trait Ulps {
    type U: Copy + NumCast;

    // Required methods
    fn ulps(&self, other: &Self) -> <Self as Ulps>::U;
    fn next(&self) -> Self;
    fn prev(&self) -> Self;
}
Expand description

A trait for floating point numbers which computes the number of representable values or ULPs (Units of Least Precision) that separate the two given values.

Required Associated Types§

Required Methods§

source

fn ulps(&self, other: &Self) -> <Self as Ulps>::U

The number of representable values or ULPs (Units of Least Precision) that separate self and other. The result U is an integral value, and will be zero if self and other are exactly equal.

source

fn next(&self) -> Self

The next representable number above this one

source

fn prev(&self) -> Self

The previous representable number below this one

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl Ulps for f32

source§

type U = i32

source§

fn ulps(&self, other: &f32) -> i32

source§

fn next(&self) -> Self

source§

fn prev(&self) -> Self

source§

impl Ulps for f64

source§

type U = i64

source§

fn ulps(&self, other: &f64) -> i64

source§

fn next(&self) -> Self

source§

fn prev(&self) -> Self

Implementors§