Struct dec::Decimal128 [−][src]
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(mut bytes: [u8; 16]) -> Decimal128
[src]
Creates a number from its representation as a little-endian byte array.
pub fn from_be_bytes(mut 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 exponent(&self) -> i32
[src]
Computes the exponent of the number.
pub fn canonical(mut self: 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.
fn add(self, rhs: Decimal128) -> Decimal128
[src]
impl Add<OrderedDecimal<Decimal128>> for Decimal128
[src]
type Output = Self
The resulting type after applying the +
operator.
fn add(self, other: OrderedDecimal<Decimal128>) -> Self
[src]
impl AddAssign<Decimal128> for Decimal128
[src]
fn add_assign(&mut self, rhs: Decimal128)
[src]
impl Clone for Decimal128
[src]
fn clone(&self) -> Decimal128
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for Decimal128
[src]
impl Debug for Decimal128
[src]
impl Default for Decimal128
[src]
fn default() -> Decimal128
[src]
impl Display for Decimal128
[src]
impl Div<Decimal128> for Decimal128
[src]
type Output = Decimal128
The resulting type after applying the /
operator.
fn div(self, rhs: Decimal128) -> Decimal128
[src]
impl Div<OrderedDecimal<Decimal128>> for Decimal128
[src]
type Output = Self
The resulting type after applying the /
operator.
fn div(self, other: OrderedDecimal<Decimal128>) -> Self
[src]
impl DivAssign<Decimal128> for Decimal128
[src]
fn div_assign(&mut self, rhs: Decimal128)
[src]
impl<const N: usize> From<Decimal128> for Decimal<N>
[src]
arbitrary-precision
only.fn from(n: Decimal128) -> Decimal<N>
[src]
impl<D> From<Decimal128> for OrderedDecimal<D> where
D: From<Decimal128>,
[src]
D: From<Decimal128>,
fn from(n: Decimal128) -> OrderedDecimal<D>
[src]
impl From<Decimal32> for Decimal128
[src]
fn from(d32: Decimal32) -> Decimal128
[src]
impl From<Decimal64> for Decimal128
[src]
fn from(d64: Decimal64) -> Decimal128
[src]
impl From<i32> for Decimal128
[src]
fn from(n: i32) -> Decimal128
[src]
impl From<u32> for Decimal128
[src]
fn from(n: u32) -> Decimal128
[src]
impl FromStr for Decimal128
[src]
type Err = ParseDecimalError
The associated error which can be returned from parsing.
fn from_str(s: &str) -> Result<Decimal128, ParseDecimalError>
[src]
impl Mul<Decimal128> for Decimal128
[src]
type Output = Decimal128
The resulting type after applying the *
operator.
fn mul(self, rhs: Decimal128) -> Decimal128
[src]
impl Mul<OrderedDecimal<Decimal128>> for Decimal128
[src]
type Output = Self
The resulting type after applying the *
operator.
fn mul(self, other: OrderedDecimal<Decimal128>) -> Self
[src]
impl MulAssign<Decimal128> for Decimal128
[src]
fn mul_assign(&mut self, rhs: Decimal128)
[src]
impl Neg for Decimal128
[src]
type Output = Decimal128
The resulting type after applying the -
operator.
fn neg(self) -> Decimal128
[src]
impl PartialEq<Decimal128> for Decimal128
[src]
impl PartialOrd<Decimal128> for Decimal128
[src]
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
#[must_use]pub fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'a> Product<&'a Decimal128> for Decimal128
[src]
fn product<I>(iter: I) -> Self where
I: Iterator<Item = &'a Decimal128>,
[src]
I: Iterator<Item = &'a Decimal128>,
impl Product<Decimal128> for Decimal128
[src]
fn product<I>(iter: I) -> Self where
I: Iterator<Item = Decimal128>,
[src]
I: Iterator<Item = Decimal128>,
impl Rem<Decimal128> for Decimal128
[src]
type Output = Decimal128
The resulting type after applying the %
operator.
fn rem(self, rhs: Decimal128) -> Decimal128
[src]
impl Rem<OrderedDecimal<Decimal128>> for Decimal128
[src]
type Output = Self
The resulting type after applying the %
operator.
fn rem(self, other: OrderedDecimal<Decimal128>) -> Self
[src]
impl RemAssign<Decimal128> for Decimal128
[src]
fn rem_assign(&mut self, rhs: Decimal128)
[src]
impl Sub<Decimal128> for Decimal128
[src]
type Output = Decimal128
The resulting type after applying the -
operator.
fn sub(self, rhs: Decimal128) -> Decimal128
[src]
impl Sub<OrderedDecimal<Decimal128>> for Decimal128
[src]
type Output = Self
The resulting type after applying the -
operator.
fn sub(self, other: OrderedDecimal<Decimal128>) -> Self
[src]
impl SubAssign<Decimal128> for Decimal128
[src]
fn sub_assign(&mut self, rhs: Decimal128)
[src]
impl<'a> Sum<&'a Decimal128> for Decimal128
[src]
fn sum<I>(iter: I) -> Self where
I: Iterator<Item = &'a Decimal128>,
[src]
I: Iterator<Item = &'a Decimal128>,
impl Sum<Decimal128> for Decimal128
[src]
fn sum<I>(iter: I) -> Self where
I: Iterator<Item = Decimal128>,
[src]
I: Iterator<Item = Decimal128>,
Auto Trait Implementations
impl RefUnwindSafe for Decimal128
[src]
impl Send for Decimal128
[src]
impl Sync for Decimal128
[src]
impl Unpin for Decimal128
[src]
impl UnwindSafe for Decimal128
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,