Struct dec::Decimal [−][src]
arbitrary-precision
only.An arbitrary-precision decimal number.
The maximum number of digits that can be stored in the number is specified
by N * 3
. For example, a value of type Decimal<3>
has space for nine
decimal digits. This somewhat odd design is due to limitations of constant
generic parameters in Rust. The intention is to someday make N
correspond
directly to the number of digits of precision.
N
must be at least 12 and no greater than 999,999,999, though typically
the stack size implies a smaller maximum for N
. Due to limitations with
constant generics it is not yet possible to enforce these restrictions
at compile time, so they are checked at runtime.
Implementations
impl<const N: usize> Decimal<N>
[src]
pub fn zero() -> Decimal<N>
[src]
Constructs a decimal number with N / 3
digits of precision
representing the number 0.
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 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_nan(&self) -> bool
[src]
Reports whether the number is a NaN.
pub fn is_negative(&self) -> bool
[src]
Reports whether the number is negative.
A negative number is either negative zero, less than zero, or NaN
with a sign of one. This corresponds to Decimal128::is_signed
, not
Decimal128::is_negative
.
pub fn is_quiet_nan(&self) -> bool
[src]
Reports whether the number is a quiet NaN.
pub fn is_signaling_nan(&self) -> bool
[src]
Reports whether the number is a signaling NaN.
pub fn is_special(&self) -> bool
[src]
Reports whether the number has a special value.
A special value is either infinity or NaN. This is the inverse of
Decimal::is_finite
.
pub fn is_zero(&self) -> bool
[src]
Reports whether the number is positive or negative zero.
pub fn quantum_matches(&self, rhs: &Decimal<N>) -> 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 to_decimal32(&self) -> Decimal32
[src]
Converts this decimal to a 32-bit decimal float.
The result may be inexact. Use Context::<Decimal32>::from_decimal
to observe exceptional conditions.
pub fn to_decimal64(&self) -> Decimal64
[src]
Converts this decimal to a 64-bit decimal float.
The result may be inexact. Use Context::<Decimal64>::from_decimal
to observe exceptional conditions.
pub fn to_decimal128(&self) -> Decimal128
[src]
Converts this decimal to a 128-bit decimal float.
The result may be inexact. Use Context::<Decimal128>::from_decimal
to observe exceptional conditions.
pub fn to_raw_parts(&self) -> (u32, i32, u8, [u16; N])
[src]
Returns the raw parts of this decimal.
The meaning of these parts are unspecified and subject to change.
Trait Implementations
impl<const N: usize> Clone for Decimal<N>
[src]
impl<const N: usize> Debug for Decimal<N>
[src]
impl<const N: usize> Default for Decimal<N>
[src]
impl<const N: usize> Display for Decimal<N>
[src]
impl<const N: usize> From<Decimal128> for Decimal<N>
[src]
fn from(n: Decimal128) -> Decimal<N>
[src]
impl<const N: usize> From<Decimal32> for Decimal<N>
[src]
impl<const N: usize> From<Decimal64> for Decimal<N>
[src]
impl<const N: usize> FromStr for Decimal<N>
[src]
type Err = ParseDecimalError
The associated error which can be returned from parsing.
fn from_str(s: &str) -> Result<Decimal<N>, ParseDecimalError>
[src]
Auto Trait Implementations
impl<const N: usize> RefUnwindSafe for Decimal<N>
[src]
impl<const N: usize> Send for Decimal<N>
[src]
impl<const N: usize> Sync for Decimal<N>
[src]
impl<const N: usize> Unpin for Decimal<N>
[src]
impl<const N: usize> UnwindSafe for Decimal<N>
[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>,