Skip to main content

Ieee64

Struct Ieee64 

Source
pub struct Ieee64(/* private fields */);
Expand description

Software IEEE-754 binary64 (53-bit significand, 11-bit exponent). Stored as u64 bits.

Implementations§

Source§

impl Ieee64

Source

pub const ZERO: Ieee64

(+0).

Source

pub const fn from_bits(bits: u64) -> Ieee64

Build from the IEEE bit pattern.

Source

pub const fn to_bits(self) -> u64

Return the IEEE bit pattern.

Source

pub fn from_i32(n: i32) -> Ieee64

Integer (n) converted with IEEE rounding.

Source

pub fn classify(self) -> FpCategory

Classify the value.

Source

pub fn is_nan(self) -> bool

True if the value is NaN.

Source

pub fn is_infinite(self) -> bool

True if the value is (\pm\infty).

Source

pub fn is_finite(self) -> bool

True if the value is finite (including zero and subnormals).

Source

pub fn is_zero(self) -> bool

True if the value is (\pm 0).

Source

pub fn is_subnormal(self) -> bool

True if the value is subnormal.

Source

pub fn is_sign_negative(self) -> bool

True if the sign bit is set.

Source

pub fn err(self) -> Option<Error>

Associated error on NaN (InvalidArgument); None otherwise.

Source

pub fn add(self, rhs: Ieee64) -> Ieee64

IEEE add (to-nearest, ties to even).

Source

pub fn sub(self, rhs: Ieee64) -> Ieee64

IEEE sub.

Source

pub fn mul(self, rhs: Ieee64) -> Ieee64

IEEE mul.

Source

pub fn div(self, rhs: Ieee64) -> Ieee64

IEEE div. (x/0) is (\pm\infty); (0/0) is NaN.

Source

pub fn sqrt(self) -> Ieee64

IEEE sqrt. Negative finite → NaN.

Source

pub fn mul_add(self, b: Ieee64, c: Ieee64) -> Ieee64

IEEE fused multiply-add (a\cdot b + c).

Source

pub fn next_up(self) -> Ieee64

Next representable value toward (+\infty).

Source

pub fn next_down(self) -> Ieee64

Next representable value toward (-\infty).

Source

pub fn next_after(self, other: Ieee64) -> Ieee64

Next representable value toward other.

Source

pub fn frexp(self) -> (Ieee64, i32)

Split as (m\cdot 2^e) with (m\in[1/2,1)) (or a special).

Source

pub fn neg(self) -> Ieee64

Negate (flip the sign bit).

Source

pub fn abs(self) -> Ieee64

Absolute value.

Source

pub fn copysign(self, sign: Ieee64) -> Ieee64

Copy the sign of sign onto self.

Source

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

Sign, or None if NaN.

Source

pub fn cmp(self, other: Ieee64) -> Option<Ordering>

Compare; None if either is NaN. (+0 = -0).

Source§

impl Ieee64

Source

pub const NAN: Ieee64

Canonical quiet NaN.

Source

pub const INFINITY: Ieee64

(+\infty).

Source

pub const NEG_INFINITY: Ieee64

(-\infty).

Source

pub const NEG_ZERO: Ieee64

(-0).

Source§

impl Ieee64

Source

pub fn to_exact(self, p: usize) -> ExactNum

Widen to ExactNum at precision p (use at least 64 bits).

Source

pub fn from_exact(x: &ExactNum) -> Ieee64

Round an ExactNum to binary64 (to-nearest, ties to even).

Source

pub fn map_exact<F>(self, p: usize, _rm: RoundingMode, op: F) -> Ieee64
where F: FnOnce(&ExactNum) -> ExactNum,

Widen then apply op, then IEEE-round back.

Trait Implementations§

Source§

impl Add for Ieee64

Source§

type Output = Ieee64

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Ieee64) -> Ieee64

Performs the + operation. Read more
Source§

impl Clone for Ieee64

Source§

fn clone(&self) -> Ieee64

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 Ieee64

Source§

impl Debug for Ieee64

Source§

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

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

impl Div for Ieee64

Source§

type Output = Ieee64

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Ieee64) -> Ieee64

Performs the / operation. Read more
Source§

impl Mul for Ieee64

Source§

type Output = Ieee64

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Ieee64) -> Ieee64

Performs the * operation. Read more
Source§

impl Neg for Ieee64

Source§

type Output = Ieee64

The resulting type after applying the - operator.
Source§

fn neg(self) -> Ieee64

Performs the unary - operation. Read more
Source§

impl PartialEq for Ieee64

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl Sub for Ieee64

Source§

type Output = Ieee64

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Ieee64) -> Ieee64

Performs the - operation. Read more

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<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> 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 = !

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.