Skip to main content

Exactly

Struct Exactly 

Source
pub struct Exactly;
Expand description

Exact comparison, as a tolerance of 0 gives, through plain IEEE comparisons and floor.

Trait Implementations§

Source§

impl Clone for Exactly

Source§

fn clone(&self) -> Exactly

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Exactly

Source§

impl Debug for Exactly

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Tolerant for Exactly

Source§

fn value(self) -> f64

The tolerance: 0 for Exactly.
Source§

fn close<F>(self, _: F, _: F) -> bool
where F: Float,

Whether x and y lie within the tolerance of each other: |x-y| is less than the tolerance times the larger of |x| and |y|. NaN and the infinities are close to nothing. less and less_equal read it without equal’s x == y, because x < y already implies x != y, and x <= y already holds where x == y.
Source§

fn floor_in<F, O>(self, o: &O, y: <O as Ops<F>>::V) -> <O as Ops<F>>::V
where F: Float, O: Ops<F> + ?Sized,

floor through o: the formula that the Floor, Ceil and Residue objects give compiled code (Facts::formula).
Source§

fn equal<F>(self, x: F, y: F) -> bool
where F: Float,

Whether x equals y: it is y, or close to it. NaN equals nothing, as in IEEE, and an infinity equals only itself.
Source§

fn floor<F>(self, y: F) -> F
where F: Float,

The floor of y: the whole number nearest to y, unless it lies above y and doesn’t equal it. Then the whole number below. A floor or ceiling that is zero is 0, never -0, as BPL’s numbers give it.
Source§

fn ceil<F>(self, y: F) -> F
where F: Float,

The ceiling of y: the whole number nearest to y, unless it lies below y and doesn’t equal it. Then the whole number above.
Source§

fn ceil_in<F, O>(self, o: &O, y: <O as Ops<F>>::V) -> <O as Ops<F>>::V
where F: Float, O: Ops<F> + ?Sized,

ceil through o.
Source§

fn matches<F>(self, x: F, y: F) -> bool
where F: Float,

Whether x and y match: they are equal, or both are NaN. A search that must find NaN compares with matches.
Source§

fn less<F>(self, x: F, y: F) -> bool
where F: Float,

Whether x is below y and doesn’t equal it. Comparisons with NaN are false.
Source§

fn less_equal<F>(self, x: F, y: F) -> bool
where F: Float,

Whether x is below y or equals it. Comparisons with NaN are false.
Source§

fn greater<F>(self, x: F, y: F) -> bool
where F: Float,

Whether x is above y and doesn’t equal it. Comparisons with NaN are false.
Source§

fn greater_equal<F>(self, x: F, y: F) -> bool
where F: Float,

Whether x is above y or equals it. Comparisons with NaN are false.
Source§

fn compare<F>(self, x: F, y: F) -> Option<Ordering>
where F: Float,

The order of x and y, which is Equal when they are equal. None when either is NaN.
Source§

fn residue<F>(self, x: F, y: F) -> F
where F: Float,

y modulo x, through recipe::residue: y - x·floor(y/x) from this tolerance’s floor of the quotient, rounded once where the target fuses multiply-add. At nonzero tolerance, a product equal to y within tolerance leaves no remainder. x = 0 gives y.
Source§

fn residue_in<F, O>( self, o: &O, x: <O as Ops<F>>::V, y: <O as Ops<F>>::V, ) -> <O as Ops<F>>::V
where F: Float, O: Ops<F> + ?Sized,

residue through o.
Source§

fn nearest_whole<F>(self, y: F) -> (F, bool)
where F: Float,

The whole number nearest y, and whether y equals it within this tolerance.
Source§

fn nearest_whole_in<F, O>( self, o: &O, y: <O as Ops<F>>::V, ) -> (<O as Ops<F>>::V, <O as Ops<F>>::B)
where F: Float, O: Ops<F> + ?Sized,

Source§

fn whole<F>(self, y: F) -> Option<F>
where F: Float,

The whole number equal to y, when there is one.
Source§

fn range<F>(self, c: F) -> Option<(F, F)>
where F: Float,

The floats equal to c, as (lo, hi): equal(x, c) holds exactly when lo <= x && x <= hi. Comparing many floats with c then takes two plain comparisons for each, in a loop that vectorizes. None when c is NaN, which equals nothing.
Source§

fn gcd<F>(self, x: F, y: F) -> F
where F: Float,

The greatest common divisor of x and y: the larger magnitude divided by the numerator of the first convergent of the ratio of the magnitudes that equals the ratio. It computes in f64 and rounds. NaN when either argument is NaN or infinite. Whole magnitudes whose product is below 1e14 take integer gcd, which gives the same result at any tolerance up to the default.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> TolerantComplex for T
where T: Tolerant,

Source§

fn complex_equal<R>(self, x: Complex<R>, y: Complex<R>) -> bool
where R: Native,

Whether x equals y: the magnitude of x-y is at most the tolerance times the larger magnitude, as Dyalog APL defines it. A number with an infinite or NaN part equals only itself, as IEEE compares it. A tolerance of 0 compares the parts exactly.
Source§

fn squared_equal<R>(self, x: Complex<R>, y: Complex<R>) -> (bool, bool)
where R: Native,

complex_equal through squared magnitudes, |x-y|² ≤ t² max(|x|², |y|²), with no branch or square root, and whether that test decides it. A tolerance of 0 compares the parts exactly, which always decides. Otherwise the test decides wherever the larger squared magnitude lies between 2^-800 and 2^1000 at f64, or 2^-80 and 2^120 at f32. In that range no square overflows, and t² times one doesn’t underflow. A NaN part gives false, as IEEE compares it.
Source§

fn scaled_equal<R>(self, x: Complex<R>, y: Complex<R>) -> bool
where R: Native,

complex_equal from the magnitudes themselves, which norm computes without overflow or underflow, for the pairs that squared_equal leaves undecided.
Source§

fn complex_floor<R>(self, y: Complex<R>) -> Complex<R>
where R: Native,

McDonnell’s complex floor: the floors of both parts, plus 1 on the part with the larger fraction when the fractions add up to 1.
Source§

fn complex_ceil<R>(self, y: Complex<R>) -> Complex<R>
where R: Native,

Source§

fn complex_residue<R>(self, x: Complex<R>, y: Complex<R>) -> Complex<R>
where R: Native,

y modulo x for complex numbers. A quotient equal to a Gaussian integer leaves no remainder. x = 0 gives y.
Source§

fn complex_gcd<R>(self, x: Complex<R>, y: Complex<R>) -> Complex<R>
where R: Native,

The greatest common divisor of x and y as complex numbers, by Euclid’s algorithm with the quotient rounded to the nearest Gaussian integer. It stops once the remainder is within the tolerance of the larger magnitude, and turns the result into the first quadrant, real part above 0. Two real numbers give gcd. A non-finite argument, or a remainder that stops shrinking, gives NaN.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.