Struct dec::Decimal64 [−][src]
A 64-bit decimal floating-point number.
Additional operations are defined as methods on the Context
type.
For convenience, Decimal64
overloads many of the standard Rust operators.
For example, you can use the standard +
operator to add two values
together:
use dec::Decimal64; let a = Decimal64::from(1); let b = Decimal64::from(2); assert_eq!(a + b, Decimal64::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 Decimal64
[src]
pub fn zero() -> Decimal64
[src]
Constructs a 128-bit decimal floating-point number representing the number 0.
pub fn from_le_bytes(mut bytes: [u8; 8]) -> Decimal64
[src]
Creates a number from its representation as a little-endian byte array.
pub fn from_be_bytes(mut bytes: [u8; 8]) -> Decimal64
[src]
Creates a number from its representation as a big-endian byte array.
pub fn from_ne_bytes(bytes: [u8; 8]) -> Decimal64
[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; 8]
[src]
Returns the memory representation of the number as a byte array in little-endian order.
pub fn to_be_bytes(&self) -> [u8; 8]
[src]
Returns the memory representation of the number as a byte array in big-endian order.
pub fn to_ne_bytes(&self) -> [u8; 8]
[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) -> Decimal64
[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: &Decimal64) -> 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: &Decimal64) -> 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<Decimal64> for Decimal64
[src]
type Output = Decimal64
The resulting type after applying the +
operator.
fn add(self, rhs: Decimal64) -> Decimal64
[src]
impl AddAssign<Decimal64> for Decimal64
[src]
fn add_assign(&mut self, rhs: Decimal64)
[src]
impl Clone for Decimal64
[src]
impl Copy for Decimal64
[src]
impl Debug for Decimal64
[src]
impl Default for Decimal64
[src]
impl Display for Decimal64
[src]
impl Div<Decimal64> for Decimal64
[src]
type Output = Decimal64
The resulting type after applying the /
operator.
fn div(self, rhs: Decimal64) -> Decimal64
[src]
impl DivAssign<Decimal64> for Decimal64
[src]
fn div_assign(&mut self, rhs: Decimal64)
[src]
impl Eq for Decimal64
[src]
impl From<Decimal32> for Decimal64
[src]
impl<const N: usize> From<Decimal64> for Decimal<N>
[src]
arbitrary-precision
only.impl From<Decimal64> for Decimal128
[src]
fn from(d64: Decimal64) -> Decimal128
[src]
impl From<i32> for Decimal64
[src]
impl From<u32> for Decimal64
[src]
impl FromStr for Decimal64
[src]
type Err = ParseDecimalError
The associated error which can be returned from parsing.
fn from_str(s: &str) -> Result<Decimal64, ParseDecimalError>
[src]
impl Mul<Decimal64> for Decimal64
[src]
type Output = Decimal64
The resulting type after applying the *
operator.
fn mul(self, rhs: Decimal64) -> Decimal64
[src]
impl MulAssign<Decimal64> for Decimal64
[src]
fn mul_assign(&mut self, rhs: Decimal64)
[src]
impl Ord for Decimal64
[src]
fn cmp(&self, other: &Self) -> Ordering
[src]
#[must_use]pub fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]
impl PartialEq<Decimal64> for Decimal64
[src]
impl PartialOrd<Decimal64> for Decimal64
[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 Rem<Decimal64> for Decimal64
[src]
type Output = Decimal64
The resulting type after applying the %
operator.
fn rem(self, rhs: Decimal64) -> Decimal64
[src]
impl RemAssign<Decimal64> for Decimal64
[src]
fn rem_assign(&mut self, rhs: Decimal64)
[src]
impl Sub<Decimal64> for Decimal64
[src]
type Output = Decimal64
The resulting type after applying the -
operator.
fn sub(self, rhs: Decimal64) -> Decimal64
[src]
impl SubAssign<Decimal64> for Decimal64
[src]
fn sub_assign(&mut self, rhs: Decimal64)
[src]
Auto Trait Implementations
impl RefUnwindSafe for Decimal64
[src]
impl Send for Decimal64
[src]
impl Sync for Decimal64
[src]
impl Unpin for Decimal64
[src]
impl UnwindSafe for Decimal64
[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>,