Struct pure_decimal::Decimal
[−]
[src]
pub struct Decimal(_);
Examples:
// Use as keys in BTree let mut map = BTreeMap::new(); map.insert(dec!(1.0), dec!(1.0)); map.insert(dec!(1), dec!(2.0)); assert!(map.len() == 1); assert!(map.contains_key(&dec!(1.00))); assert!(map.get(&dec!(1.00)) == Some(&dec!(2.0)));
Methods
impl Decimal
[src]
fn zero() -> Self
[src]
Creates a Decimal with 0
as value
fn max<O: AsRef<Decimal>>(self, other: O) -> Decimal
[src]
returns the larger of self
and other
fn min<O: AsRef<Decimal>>(self, other: O) -> Decimal
[src]
returns the smaller of self
and other
fn abs(&self) -> Decimal
[src]
returns absolute value of self
fn mul_add<O: AsRef<Decimal>>(self, a: O, b: O) -> Decimal
[src]
Calculates the fused multiply-add self
× a
+ b
and returns the result. The multiply
is carried out first and is exact, so this operation has only the one, final, rounding.
fn is_negative(&self) -> bool
[src]
returns true if self
is less than zero
fn is_positive(&self) -> bool
[src]
fn is_zero(&self) -> bool
[src]
returns true if self
is zero
fn pow<O: AsRef<Decimal>>(self, exp: O) -> Decimal
[src]
see [decimal::d128::pow]
Trait Implementations
impl Clone for Decimal
[src]
fn clone(&self) -> Decimal
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Copy for Decimal
[src]
impl Default for Decimal
[src]
impl Hash for Decimal
[src]
fn hash<H: Hasher>(&self, state: &mut H)
[src]
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl FromStr for Decimal
[src]
type Err = Error
The associated error which can be returned from parsing.
fn from_str(s: &str) -> Result<Self, Error>
[src]
Parses a string s
to return a value of this type. Read more
impl Display for Decimal
[src]
Delegates to d128.
fn fmt(&self, fmt: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl Debug for Decimal
[src]
Delegates to d128.
impl LowerExp for Decimal
[src]
Delegates to d128.
impl LowerHex for Decimal
[src]
Delegates to d128.
impl PartialEq<Decimal> for Decimal
[src]
fn eq(&self, other: &Decimal) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl Eq for Decimal
[src]
impl PartialOrd<Decimal> for Decimal
[src]
fn partial_cmp(&self, other: &Decimal) -> Option<Ordering>
[src]
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl Ord for Decimal
[src]
fn cmp(&self, other: &Decimal) -> Ordering
[src]
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
1.22.0[src]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.22.0[src]
Compares and returns the minimum of two values. Read more
impl From<i32> for Decimal
[src]
impl From<u32> for Decimal
[src]
Converts an u32 to d128. The result is exact and no error is possible.
impl From<u64> for Decimal
[src]
Converts an u64 to d128. The result is exact and no error is possible.
impl From<i64> for Decimal
[src]
Converts an i64 to d128. The result is exact and no error is possible.
impl AsRef<Decimal> for Decimal
[src]
impl Neg for Decimal
[src]
type Output = Decimal
The resulting type after applying the -
operator.
fn neg(self) -> Decimal
[src]
Performs the unary -
operation.
impl<'a> Neg for &'a Decimal
[src]
type Output = Decimal
The resulting type after applying the -
operator.
fn neg(self) -> Decimal
[src]
Performs the unary -
operation.
impl Add<Decimal> for Decimal
[src]
type Output = Decimal
The resulting type after applying the +
operator.
fn add(self, other: Decimal) -> Decimal
[src]
Performs the +
operation.
impl<'a> Add<Decimal> for &'a Decimal
[src]
type Output = Decimal
The resulting type after applying the +
operator.
fn add(self, other: Decimal) -> Decimal
[src]
Performs the +
operation.
impl<'a> Add<&'a Decimal> for Decimal
[src]
type Output = Decimal
The resulting type after applying the +
operator.
fn add(self, other: &'a Decimal) -> Decimal
[src]
Performs the +
operation.
impl<'a, 'b> Add<&'a Decimal> for &'b Decimal
[src]
type Output = Decimal
The resulting type after applying the +
operator.
fn add(self, other: &'a Decimal) -> Decimal
[src]
Performs the +
operation.
impl Sub<Decimal> for Decimal
[src]
type Output = Decimal
The resulting type after applying the -
operator.
fn sub(self, other: Decimal) -> Decimal
[src]
Performs the -
operation.
impl<'a> Sub<Decimal> for &'a Decimal
[src]
type Output = Decimal
The resulting type after applying the -
operator.
fn sub(self, other: Decimal) -> Decimal
[src]
Performs the -
operation.
impl<'a> Sub<&'a Decimal> for Decimal
[src]
type Output = Decimal
The resulting type after applying the -
operator.
fn sub(self, other: &'a Decimal) -> Decimal
[src]
Performs the -
operation.
impl<'a, 'b> Sub<&'a Decimal> for &'b Decimal
[src]
type Output = Decimal
The resulting type after applying the -
operator.
fn sub(self, other: &'a Decimal) -> Decimal
[src]
Performs the -
operation.
impl Mul<Decimal> for Decimal
[src]
type Output = Decimal
The resulting type after applying the *
operator.
fn mul(self, other: Decimal) -> Decimal
[src]
Performs the *
operation.
impl<'a> Mul<Decimal> for &'a Decimal
[src]
type Output = Decimal
The resulting type after applying the *
operator.
fn mul(self, other: Decimal) -> Decimal
[src]
Performs the *
operation.
impl<'a> Mul<&'a Decimal> for Decimal
[src]
type Output = Decimal
The resulting type after applying the *
operator.
fn mul(self, other: &'a Decimal) -> Decimal
[src]
Performs the *
operation.
impl<'a, 'b> Mul<&'a Decimal> for &'b Decimal
[src]
type Output = Decimal
The resulting type after applying the *
operator.
fn mul(self, other: &'a Decimal) -> Decimal
[src]
Performs the *
operation.
impl Div<Decimal> for Decimal
[src]
type Output = Result<Decimal, Error>
The resulting type after applying the /
operator.
fn div(self, other: Decimal) -> Result<Decimal, Error>
[src]
Returns Ok(Decimal)
if result is finite Err
otherwise
impl<'a> Div<Decimal> for &'a Decimal
[src]
type Output = Result<Decimal, Error>
The resulting type after applying the /
operator.
fn div(self, other: Decimal) -> Result<Decimal, Error>
[src]
Returns Ok(Decimal)
if result is finite Err
otherwise
impl<'a> Div<&'a Decimal> for Decimal
[src]
type Output = Result<Decimal, Error>
The resulting type after applying the /
operator.
fn div(self, other: &'a Decimal) -> Result<Decimal, Error>
[src]
Returns Ok(Decimal)
if result is finite Err
otherwise
impl<'a, 'b> Div<&'a Decimal> for &'b Decimal
[src]
type Output = Result<Decimal, Error>
The resulting type after applying the /
operator.
fn div(self, other: &'a Decimal) -> Result<Decimal, Error>
[src]
Returns Ok(Decimal)
if result is finite Err
otherwise
impl Rem<Decimal> for Decimal
[src]
type Output = Result<Decimal, Error>
The resulting type after applying the %
operator.
fn rem(self, other: Decimal) -> Result<Decimal, Error>
[src]
Returns Ok(Decimal)
if result is finite Err
otherwise
impl<'a> Rem<Decimal> for &'a Decimal
[src]
type Output = Result<Decimal, Error>
The resulting type after applying the %
operator.
fn rem(self, other: Decimal) -> Result<Decimal, Error>
[src]
Returns Ok(Decimal)
if result is finite Err
otherwise
impl<'a> Rem<&'a Decimal> for Decimal
[src]
type Output = Result<Decimal, Error>
The resulting type after applying the %
operator.
fn rem(self, other: &'a Decimal) -> Result<Decimal, Error>
[src]
Returns Ok(Decimal)
if result is finite Err
otherwise
impl<'a, 'b> Rem<&'a Decimal> for &'b Decimal
[src]
type Output = Result<Decimal, Error>
The resulting type after applying the %
operator.
fn rem(self, other: &'a Decimal) -> Result<Decimal, Error>
[src]
Returns Ok(Decimal)
if result is finite Err
otherwise
impl AddAssign<Decimal> for Decimal
[src]
fn add_assign(&mut self, other: Decimal)
[src]
Performs the +=
operation.
impl SubAssign<Decimal> for Decimal
[src]
fn sub_assign(&mut self, other: Decimal)
[src]
Performs the -=
operation.
impl MulAssign<Decimal> for Decimal
[src]
fn mul_assign(&mut self, other: Decimal)
[src]
Performs the *=
operation.
impl<T> Sum<T> for Decimal where
T: Borrow<Decimal>,
[src]
T: Borrow<Decimal>,
fn sum<I: IntoIterator<Item = T>>(iter: I) -> Decimal
[src]
Method which takes an iterator and generates Self
from the elements by "summing up" the items. Read more
impl Serialize for Decimal
[src]
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where
S: Serializer,
[src]
S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl<'de> Deserialize<'de> for Decimal
[src]
fn deserialize<D>(deserializer: D) -> Result<Decimal, D::Error> where
D: Deserializer<'de>,
[src]
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more