UlpsEq in approx - Rust
Description: Equality comparisons between two numbers using both the absolute difference and ULPs (Units in Last Place) based comparisons.
Keywords: rust, rustlang, rust-lang, UlpsEq

# Trait approx::UlpsEq

source ·

    pub trait UlpsEq<Rhs = Self>: AbsDiffEq<Rhs>where
        Rhs: ?Sized,{
        fn default_max_ulps() -> u32;
        fn ulps_eq(&self, other: &Rhs, epsilon: Self::Epsilon, max_ulps: u32) -> bool;

        fn ulps_ne(&self, other: &Rhs, epsilon: Self::Epsilon, max_ulps: u32) -> bool { ... }
    }

Expand description

Equality comparisons between two numbers using both the absolute difference and ULPs (Units in Last Place) based comparisons.

## Required Methods§

source

#### fn default_max_ulps() -> u32

The default ULPs to tolerate when testing values that are far-apart.

This is used when no `max_ulps` value is supplied to the [`ulps_eq`] macro.

source

#### fn ulps_eq(&self, other: &Rhs, epsilon: Self::Epsilon, max_ulps: u32) -> bool

A test for equality that uses units in the last place (ULP) if the values are far apart.

## Provided Methods§

source

#### fn ulps_ne(&self, other: &Rhs, epsilon: Self::Epsilon, max_ulps: u32) -> bool

The inverse of `UlpsEq::ulps_eq`.

## Implementations on Foreign Types§

source§

### impl UlpsEq<f32> for f32

source§

#### fn default_max_ulps() -> u32

source§

#### fn ulps_eq(&self, other: &f32, epsilon: f32, max_ulps: u32) -> bool

source§

### impl UlpsEq<f64> for f64

source§

#### fn default_max_ulps() -> u32

source§

#### fn ulps_eq(&self, other: &f64, epsilon: f64, max_ulps: u32) -> bool

source§

### impl<'a, T: UlpsEq + ?Sized> UlpsEq<&'a T> for &'a T

source§

#### fn default_max_ulps() -> u32

source§

#### fn ulps_eq(&self, other: &&'a T, epsilon: T::Epsilon, max_ulps: u32) -> bool

source§

### impl<'a, T: UlpsEq + ?Sized> UlpsEq<&'a mut T> for &'a mut T

source§

#### fn default_max_ulps() -> u32

source§

#### fn ulps_eq(&self, other: &&'a mut T, epsilon: T::Epsilon, max_ulps: u32) -> bool

source§

### impl<T: UlpsEq + Copy> UlpsEq<Cell<T>> for Cell<T>

source§

#### fn default_max_ulps() -> u32

source§

#### fn ulps_eq(&self, other: &Cell<T>, epsilon: T::Epsilon, max_ulps: u32) -> bool

source§

### impl<T: UlpsEq + ?Sized> UlpsEq<RefCell<T>> for RefCell<T>

source§

#### fn default_max_ulps() -> u32

source§

#### fn ulps_eq(&self, other: &RefCell<T>, epsilon: T::Epsilon, max_ulps: u32) -> bool

source§

### impl<A, B> UlpsEq<[B]> for [A]where
A: UlpsEq<B>,
A::Epsilon: Clone,

source§

#### fn default_max_ulps() -> u32

source§

#### fn ulps_eq(&self, other: &[B], epsilon: A::Epsilon, max_ulps: u32) -> bool

## Implementors§