pub struct Decimal { /* private fields */ }
Expand description
It stores the decimal in a fix point encoding allowing nearly 18 digits before and 18 digits after “.”.
It stores the value in a i128
integer after multiplying it by 10¹⁸.
Implementations§
Source§impl Decimal
impl Decimal
pub const MAX: Decimal
pub const MIN: Decimal
pub const PRECISION: u8 = 36u8
pub const SCALE: i8 = 16i8
Sourcepub const fn new(i: i128, n: u32) -> Result<Decimal, TooLargeForDecimalError>
pub const fn new(i: i128, n: u32) -> Result<Decimal, TooLargeForDecimalError>
Constructs the decimal i / 10^n
pub const fn new_from_i128_unchecked(value: i128) -> Decimal
pub fn from_be_bytes(bytes: [u8; 16]) -> Decimal
pub fn to_be_bytes(self) -> [u8; 16]
Sourcepub fn checked_add(self, rhs: impl Into<Decimal>) -> Result<Decimal, ThinError>
pub fn checked_add(self, rhs: impl Into<Decimal>) -> Result<Decimal, ThinError>
Returns Err
in case of overflow (FOAR0002).
Sourcepub fn checked_sub(self, rhs: impl Into<Decimal>) -> Result<Decimal, ThinError>
pub fn checked_sub(self, rhs: impl Into<Decimal>) -> Result<Decimal, ThinError>
Returns Err
in case of overflow (FOAR0002).
Sourcepub fn checked_mul(self, rhs: impl Into<Decimal>) -> Result<Decimal, ThinError>
pub fn checked_mul(self, rhs: impl Into<Decimal>) -> Result<Decimal, ThinError>
Returns Err
in case of overflow (FOAR0002).
Sourcepub fn checked_div(self, rhs: impl Into<Decimal>) -> Result<Decimal, ThinError>
pub fn checked_div(self, rhs: impl Into<Decimal>) -> Result<Decimal, ThinError>
Sourcepub fn checked_rem(self, rhs: impl Into<Decimal>) -> Option<Decimal>
pub fn checked_rem(self, rhs: impl Into<Decimal>) -> Option<Decimal>
Sourcepub fn checked_neg(self) -> Result<Decimal, ThinError>
pub fn checked_neg(self) -> Result<Decimal, ThinError>
Returns Err
in case of overflow (FOAR0002).
Sourcepub fn checked_abs(self) -> Result<Decimal, ThinError>
pub fn checked_abs(self) -> Result<Decimal, ThinError>
Sourcepub fn checked_round(self) -> Result<Decimal, ThinError>
pub fn checked_round(self) -> Result<Decimal, ThinError>
Sourcepub fn checked_ceil(self) -> Result<Decimal, ThinError>
pub fn checked_ceil(self) -> Result<Decimal, ThinError>
Returns Err
in case of overflow (FOAR0002).
Sourcepub fn checked_floor(self) -> Result<Decimal, ThinError>
pub fn checked_floor(self) -> Result<Decimal, ThinError>
pub const fn is_negative(self) -> bool
pub const fn is_positive(self) -> bool
Sourcepub fn is_identical_with(self, other: Decimal) -> bool
pub fn is_identical_with(self, other: Decimal) -> bool
Checks if the two values are identical.
pub const fn as_i128(self) -> i128
Trait Implementations§
Source§impl Ord for Decimal
impl Ord for Decimal
Source§impl PartialOrd for Decimal
impl PartialOrd for Decimal
impl Copy for Decimal
impl Eq for Decimal
impl StructuralPartialEq for Decimal
Auto Trait Implementations§
impl Freeze for Decimal
impl RefUnwindSafe for Decimal
impl Send for Decimal
impl Sync for Decimal
impl Unpin for Decimal
impl UnwindSafe for Decimal
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more