Skip to main content

Double

Struct Double 

Source
pub struct Double(pub u64);
Expand description

An IEEE binary64 bit pattern. The sign occupies bit 63, the biased exponent bits 52–62 (bias 1023), and the fraction bits 0–51. Finite normal values have 53 significant bits. Equality compares encodings.

Tuple Fields§

§0: u64

Implementations§

Source§

impl Double

Source

pub fn add<N: NanPolicy<Double>>( self, addend: Double, rounding: Rounding, ) -> Computed<Double>

Adds the operands. Opposite infinities give the default NaN with INVALID. Exact cancellation gives −0 under round-toward-negative and +0 otherwise. Two zeros of the same sign keep that sign. NaNs use crate::nan::NanPolicy::choose.

Source

pub fn subtract<N: NanPolicy<Double>>( self, subtrahend: Double, rounding: Rounding, ) -> Computed<Double>

Subtracts the second operand. Like-signed infinities give the default NaN with INVALID. Zero signs follow addition with the second sign reversed. NaN selection receives the original operands in subtraction order.

Source§

impl Double

Source

pub fn compare<N: NanPolicy<Double>>( self, other: Double, signalling: bool, ) -> (Relation, Flags)

Compares the operands. Signed zeros compare equal. A NaN gives Unordered. A signalling comparison raises INVALID for any NaN. A quiet comparison raises it only for a signalling NaN.

Source§

impl Double

Source

pub fn to_i32( self, rounding: Rounding, ) -> Result<Rounded<i32>, InvalidConversion>

Rounds to a signed integer, then checks the destination range. Returns crate::InvalidConversion for NaN, infinity or an out-of-range rounded value. On success, inexact records a discarded nonzero fraction.

Source

pub fn to_i64( self, rounding: Rounding, ) -> Result<Rounded<i64>, InvalidConversion>

Rounds to a signed integer, then checks the destination range. Returns crate::InvalidConversion for NaN, infinity or an out-of-range rounded value. On success, inexact records a discarded nonzero fraction.

Source

pub fn from_i32(value: i32) -> Double

Converts an i32 exactly to binary64.

Source

pub fn from_i64(value: i64) -> Computed<Self>

Converts an i64 to this format. Zero finishes as +0. Nonzero inputs return an exact intermediate to round at the destination precision.

Source

pub fn from_single<N: NanPolicy<Self> + NanPolicy<Single>>( value: Single, ) -> (Self, Flags)

Widens exactly, preserving the sign of zeros and infinities. For NaNs, the source policy exports the payload and the destination policy imports it.

Source

pub fn to_single<N: NanPolicy<Self> + NanPolicy<Single>>( self, ) -> Computed<Single>

Narrows a finite nonzero operand through an exact intermediate. Returns a finished signed zero, signed infinity or policy-converted NaN for other inputs.

Source§

impl Double

Source

pub fn divide<N: NanPolicy<Double>>(self, divisor: Double) -> Computed<Double>

Divides by the second operand. Zero divided by zero and infinity divided by infinity give the default NaN with INVALID. A finite nonzero dividend over zero gives signed infinity with DIVIDE_BY_ZERO. NaNs use crate::nan::NanPolicy::choose. For other operands the quotient sign is the exclusive OR of the signs.

Source§

impl Double

Source

pub fn next_up(self) -> Self

Returns the next representable value toward positive infinity. Either signed zero steps to the smallest positive subnormal. Positive infinity and every NaN retain their exact bit patterns.

Source

pub fn next_down(self) -> Self

Returns the next representable value toward negative infinity. Either signed zero steps to the smallest negative subnormal. Negative infinity and every NaN retain their exact bit patterns.

Source

pub fn negative(self) -> bool

Returns the sign bit, including for zero and NaN.

Source

pub fn exponent(self) -> i32

Returns the raw biased exponent field.

Source

pub fn fraction(self) -> u64

Returns the unsigned fraction field.

Source

pub fn is_nan(self) -> bool

Returns true for a NaN encoding.

Source

pub fn is_denormal(self) -> bool

Returns true for a zero exponent field with a nonzero fraction.

Source

pub fn zero(negative: bool) -> Self

Encodes zero with the given sign.

Source§

impl Double

Source

pub fn multiply<N: NanPolicy<Double>>( self, multiplier: Double, ) -> Computed<Double>

Multiplies the operands. Zero times infinity gives the default NaN with INVALID. The product sign is the exclusive OR of the signs. NaNs use crate::nan::NanPolicy::choose.

Source§

impl Double

Source

pub fn sqrt<N: NanPolicy<Double>>(self) -> Computed<Double>

Computes the square root. Preserves signed zero and positive infinity. A negative nonzero operand gives the default NaN with INVALID. A NaN uses crate::nan::NanPolicy::quiet.

Trait Implementations§

Source§

impl Binary for Double

Source§

fn add(a: Self, b: Self) -> Rounded<Self>

Adds two operands with the rounding used by add.
Source§

fn subtract(a: Self, b: Self) -> Rounded<Self>

Computes the difference returned by subtract.
Source§

fn multiply(a: Self, b: Self) -> Rounded<Self>

Computes the product returned by multiply.
Source§

fn divide(a: Self, b: Self) -> Rounded<Self>

Computes the quotient returned by divide.
Source§

fn sqrt(a: Self) -> Rounded<Self>

Computes the square root returned by sqrt.
Source§

impl Clone for Double

Source§

fn clone(&self) -> Self

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 Double

Source§

impl Debug for Double

Source§

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

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

impl Eq for Double

Source§

impl NanPolicy<Double> for X86

Source§

const DEFAULT: Double

NaN returned for an invalid operation with no NaN operand.
Source§

fn is_signalling(value: Double) -> bool

Returns true only for a NaN this policy classifies as signalling.
Source§

fn quiet(value: Double) -> (Double, Flags)

Quiets the NaN value for a unary operation. Return the result and Flags::INVALID if the operation signals invalid, or Flags::NONE otherwise.
Source§

fn choose(first: Double, second: Double) -> (Double, Flags)

Selects a quiet NaN when one or both operands are NaNs. Return the result and Flags::INVALID if the policy signals invalid, or Flags::NONE otherwise. Subtraction passes the original signs.
Source§

fn export(value: Double) -> Payload

Exports the sign, signalling status and left-aligned payload of a source NaN.
Source§

fn import(payload: Payload) -> (Double, Flags)

Constructs a quiet destination NaN. Return Flags::INVALID if this conversion signals invalid operation, or Flags::NONE otherwise.
Source§

impl PartialEq for Double

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl Real for Double

Source§

const DEFAULT_NAN: Self

The default NaN. It is negative and quiet, with a zero payload.
Source§

fn is_signalling_nan(value: Self) -> bool

Tests whether the operand is a signalling NaN.
Source§

fn negative(value: Self) -> bool

Returns the sign bit, including for zero and NaN.
Source§

fn is_nan(value: Self) -> bool

Tests whether the operand is a NaN.
Source§

fn is_denormal(value: Self) -> bool

Tests whether the operand is denormal: a zero exponent field and a nonzero fraction.
Source§

fn zero(negative: bool) -> Self

Encodes zero with the given sign.
Source§

fn add(a: Self, b: Self, rounding: Rounding) -> Computed<Self>

Adds two lanes. See crate::Single::add for the operand cases. NaNs and exceptions follow the x86 rules.
Source§

fn subtract(a: Self, b: Self, rounding: Rounding) -> Computed<Self>

Subtracts the second lane from the first. See crate::Single::subtract for the operand cases. NaNs and exceptions follow the x86 rules.
Source§

fn multiply(a: Self, b: Self) -> Computed<Self>

Multiplies two lanes. See crate::Single::multiply for the operand cases. NaNs and exceptions follow the x86 rules.
Source§

fn divide(a: Self, b: Self) -> Computed<Self>

Divides the first lane by the second. See crate::Single::divide for the operand cases. NaNs and exceptions follow the x86 rules.
Source§

fn sqrt(a: Self) -> Computed<Self>

Takes the square root of a lane. See crate::Single::sqrt for the operand cases. NaNs and exceptions follow the x86 rules.
Source§

fn compare(a: Self, b: Self, signalling: bool) -> (Relation, Flags)

Compares two lanes. See crate::Single::compare for the operand cases. NaNs and exceptions follow the x86 rules.
Source§

fn to_i32(value: Self, rounding: Rounding) -> Rounded<i32>

Rounds to the destination integer width. NaN, infinity or an out-of-range rounded value returns the most negative integer with invalid alone.
Source§

fn from_i64(value: i64) -> Computed<Self>

Converts a signed 64-bit integer. A nonzero result goes through the destination rounding.
Source§

fn to_i64(value: Self, rounding: Rounding) -> Rounded<i64>

Rounds to a signed 64-bit integer. NaN, infinity or an out-of-range rounded value returns the most negative integer with invalid alone.
Source§

fn round(value: Unrounded<Self>, rounding: Rounding) -> Rounded<Self>

Applies the masked response. It rounds on the format’s grid, overflows to infinity or the largest finite value, and underflows onto the denormal grid.
Source§

fn unmasked_flags(value: Unrounded<Self>, rounding: Rounding) -> Flags

Returns the flags of the unmasked response: overflow for a result above the format’s range, underflow for a tiny result and inexact for inexact rounding at the format’s precision with an unbounded exponent. The instruction caller suppresses the destination write.
Source§

fn from_i32(value: i32) -> Computed<Double>

Converts a signed 32-bit integer. Binary64 finishes exactly. A nonzero binary32 result goes through the destination rounding.
Source§

impl StructuralPartialEq for Double

Auto Trait Implementations§

§

impl Forget for Double

§

impl Freeze for Double

§

impl Move for Double

§

impl RefUnwindSafe for Double

§

impl Send for Double

§

impl Sync for Double

§

impl Unpin for Double

§

impl UnsafeUnpin for Double

§

impl UnwindSafe for Double

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, 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.