Struct dec::Decimal128[][src]

pub struct Decimal128 { /* fields omitted */ }

A 128-bit decimal floating-point number.

Additional operations are defined as methods on the Context type.

For convenience, Decimal128 overloads many of the standard Rust operators. For example, you can use the standard + operator to add two values together:

use dec::Decimal128;
let a = Decimal128::from(1);
let b = Decimal128::from(2);
assert_eq!(a + b, Decimal128::from(3));

These overloaded operators implicitly construct a single-use default context, which has some performance overhead. For maximum performance when performing operations in bulk, use a long-lived context that you construct yourself.

Implementations

impl Decimal128[src]

pub const NAN: Decimal128[src]

The value that represents Not-a-Number (NaN).

pub const ZERO: Decimal128[src]

The value that represents zero.

pub const ONE: Decimal128[src]

The value that represents one.

pub fn from_le_bytes(bytes: [u8; 16]) -> Decimal128[src]

Creates a number from its representation as a little-endian byte array.

pub fn from_be_bytes(bytes: [u8; 16]) -> Decimal128[src]

Creates a number from its representation as a big-endian byte array.

pub const fn from_ne_bytes(bytes: [u8; 16]) -> Decimal128[src]

Creates a number from its representation as a byte array in the native endianness of the target platform.

pub fn to_le_bytes(&self) -> [u8; 16][src]

Returns the memory representation of the number as a byte array in little-endian order.

pub fn to_be_bytes(&self) -> [u8; 16][src]

Returns the memory representation of the number as a byte array in big-endian order.

pub fn to_ne_bytes(&self) -> [u8; 16][src]

Returns the memory representation of the number as a byte array in the native endianness of the target platform.

pub fn class(&self) -> Class[src]

Classifies the number.

pub fn digits(&self) -> u32[src]

Computes the number of significant digits in the number.

If the number is zero or infinite, returns 1. If the number is a NaN, returns the number of digits in the payload.

pub fn coefficient(&self) -> i128[src]

Computes the coefficient of the number.

If the number is a special value (i.e., NaN or infinity), returns zero.

pub fn exponent(&self) -> i32[src]

Computes the exponent of the number.

pub fn canonical(self) -> Decimal128[src]

Returns an equivalent number whose encoding is guaranteed to be canonical.

pub fn is_canonical(&self) -> bool[src]

Reports whether the encoding of the number is canonical.

pub fn is_finite(&self) -> bool[src]

Reports whether the number is finite.

A finite number is one that is neither infinite nor a NaN.

pub fn is_infinite(&self) -> bool[src]

Reports whether the number is positive or negative infinity.

pub fn is_integer(&self) -> bool[src]

Reports whether the number is an integer.

An integer is a decimal number that is finite and has an exponent of zero.

pub fn is_logical(&self) -> bool[src]

Reports whether the number is a valid argument for logical operations.

A number is a valid argument for logical operations if it is a nonnegative integer where each digit is either zero or one.

pub fn is_nan(&self) -> bool[src]

Reports whether the number is a NaN.

pub fn is_negative(&self) -> bool[src]

Reports whether the number is less than zero and not a NaN.

pub fn is_normal(&self) -> bool[src]

Reports whether the number is normal.

A normal number is finite, non-zero, and not subnormal.

pub fn is_positive(&self) -> bool[src]

Reports whether the number is greater than zero and not a NaN.

pub fn is_signaling_nan(&self) -> bool[src]

Reports whether the number is a signaling NaN.

pub fn is_signed(&self) -> bool[src]

Reports whether the number has a sign of 1.

Note that zeros and NaNs may have a sign of 1.

pub fn is_subnormal(&self) -> bool[src]

Reports whether the number is subnormal.

A subnormal number is finite, non-zero, and has magnitude less than 10emin.

pub fn is_zero(&self) -> bool[src]

Reports whether the number is positive or negative zero.

pub fn quantum_matches(&self, rhs: &Decimal128) -> bool[src]

Reports whether the quantum of the number matches the quantum of rhs.

Quantums are considered to match if the numbers have the same exponent, are both NaNs, or both infinite.

pub fn total_cmp(&self, rhs: &Decimal128) -> Ordering[src]

Determines the ordering of this number relative to rhs, using the total order predicate defined in IEEE 754-2008.

For a brief description of the ordering, consult f32::total_cmp.

Trait Implementations

impl Add<Decimal128> for Decimal128[src]

type Output = Decimal128

The resulting type after applying the + operator.

impl Add<OrderedDecimal<Decimal128>> for Decimal128[src]

type Output = Self

The resulting type after applying the + operator.

impl AddAssign<Decimal128> for Decimal128[src]

impl Clone for Decimal128[src]

impl Copy for Decimal128[src]

impl Debug for Decimal128[src]

impl Default for Decimal128[src]

impl Display for Decimal128[src]

impl Div<Decimal128> for Decimal128[src]

type Output = Decimal128

The resulting type after applying the / operator.

impl Div<OrderedDecimal<Decimal128>> for Decimal128[src]

type Output = Self

The resulting type after applying the / operator.

impl DivAssign<Decimal128> for Decimal128[src]

impl<const N: usize> From<Decimal128> for Decimal<N>[src]

This is supported on crate feature arbitrary-precision only.

impl<D> From<Decimal128> for OrderedDecimal<D> where
    D: From<Decimal128>, 
[src]

impl From<Decimal32> for Decimal128[src]

impl From<Decimal64> for Decimal128[src]

impl From<i32> for Decimal128[src]

impl From<i64> for Decimal128[src]

impl From<u32> for Decimal128[src]

impl From<u64> for Decimal128[src]

impl FromStr for Decimal128[src]

type Err = ParseDecimalError

The associated error which can be returned from parsing.

impl Mul<Decimal128> for Decimal128[src]

type Output = Decimal128

The resulting type after applying the * operator.

impl Mul<OrderedDecimal<Decimal128>> for Decimal128[src]

type Output = Self

The resulting type after applying the * operator.

impl MulAssign<Decimal128> for Decimal128[src]

impl Neg for Decimal128[src]

type Output = Decimal128

The resulting type after applying the - operator.

impl PartialEq<Decimal128> for Decimal128[src]

impl PartialOrd<Decimal128> for Decimal128[src]

impl<'a> Product<&'a Decimal128> for Decimal128[src]

impl Product<Decimal128> for Decimal128[src]

impl Rem<Decimal128> for Decimal128[src]

type Output = Decimal128

The resulting type after applying the % operator.

impl Rem<OrderedDecimal<Decimal128>> for Decimal128[src]

type Output = Self

The resulting type after applying the % operator.

impl RemAssign<Decimal128> for Decimal128[src]

impl Sub<Decimal128> for Decimal128[src]

type Output = Decimal128

The resulting type after applying the - operator.

impl Sub<OrderedDecimal<Decimal128>> for Decimal128[src]

type Output = Self

The resulting type after applying the - operator.

impl SubAssign<Decimal128> for Decimal128[src]

impl<'a> Sum<&'a Decimal128> for Decimal128[src]

impl Sum<Decimal128> for Decimal128[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.