Struct Dyadic

Source
pub struct Dyadic { /* private fields */ }
Expand description

An exact value mantissa * 2^exponent.

Implementations§

Source§

impl Dyadic

Source

pub fn zero() -> Self

Zero.

Source

pub fn from_parts(mantissa: BigInt, exponent: i64) -> Self

mantissa * 2^exponent, normalised.

Source

pub fn try_from_f64(value: f64) -> Option<Self>

The exact value of a finite f64, or None for NaN and infinities.

Source

pub fn mantissa(&self) -> &BigInt

The mantissa of the normalised form.

Source

pub fn exponent(&self) -> i64

The power-of-two exponent of the normalised form.

Source

pub fn enclosure(&self) -> Interval

A sound f64 interval containing the value.

The top 64 mantissa bits are taken with a floor shift (the value lies within one unit of them), converted with one rounding, then scaled by an exact power of two and widened two steps each way, which covers both errors even at a binade boundary. Values whose scaled result would leave the normal f64 range get the whole line: sound, and never decisive.

Source

pub fn approx_parts(&self) -> (f64, i64)

(m, e) with the value within a relative 2^-52 of m * 2^e, where m is a double of magnitude in [2^52, 2^53), or (0, 0).

Unlike Dyadic::to_f64 this never overflows or underflows, so ratios and roots of huge or tiny values stay accurate: combine the parts first, apply the exponent last. For output only.

Source

pub fn bits(&self) -> u64

Bits in the mantissa: the cost driver of every operation.

Source

pub fn to_f64(&self) -> f64

A nearby double, for output only; never for decisions.

Takes the top 64 mantissa bits, so the result is within a few ulps of the value. Overflows to an infinity and underflows to zero like any f64 conversion.

Trait Implementations§

Source§

impl Arith for Dyadic

Source§

fn from_f64(value: f64) -> Self

§Panics

On NaN or an infinity, which have no exact value. The public entry points reject them first (crate::require_finite).

Source§

fn from_dyadic(value: &Dyadic) -> Self

The value of an exact dyadic number: itself in the exact tier, a sound enclosure in the interval tier (Dyadic::enclosure). Read more
Source§

fn add(&self, other: &Self) -> Self

self + other.
Source§

fn sub(&self, other: &Self) -> Self

self - other.
Source§

fn mul(&self, other: &Self) -> Self

self * other.
Source§

fn neg(&self) -> Self

-self.
Source§

fn sign(&self) -> Option<Sign>

The sign, or None when this arithmetic cannot decide it. Read more
Source§

fn sqrt_enclosure(&self) -> Option<Self>

An enclosure of sqrt(self), for approximate arithmetics only. Read more
Source§

fn square(&self) -> Self

self * self.
Source§

impl Clone for Dyadic

Source§

fn clone(&self) -> Dyadic

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Dyadic

Source§

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

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

impl Hash for Dyadic

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Dyadic

Source§

fn eq(&self, other: &Dyadic) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for Dyadic

Source§

impl StructuralPartialEq for Dyadic

Auto Trait Implementations§

§

impl Freeze for Dyadic

§

impl RefUnwindSafe for Dyadic

§

impl Send for Dyadic

§

impl Sync for Dyadic

§

impl Unpin for Dyadic

§

impl UnwindSafe for Dyadic

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<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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.