#[repr(packed(8))]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: Self
pub const MIN: Self
Sourcepub const fn new(i: i128, n: u32) -> Result<Self, TooLargeForDecimalError>
pub const fn new(i: i128, n: u32) -> Result<Self, TooLargeForDecimalError>
Constructs the decimal i / 10^n
pub fn from_be_bytes(bytes: [u8; 16]) -> Self
pub fn to_be_bytes(self) -> [u8; 16]
Sourcepub fn checked_add(self, rhs: impl Into<Self>) -> Option<Self>
pub fn checked_add(self, rhs: impl Into<Self>) -> Option<Self>
Returns None
in case of overflow (FOAR0002).
Sourcepub fn checked_sub(self, rhs: impl Into<Self>) -> Option<Self>
pub fn checked_sub(self, rhs: impl Into<Self>) -> Option<Self>
Returns None
in case of overflow (FOAR0002).
Sourcepub fn checked_mul(self, rhs: impl Into<Self>) -> Option<Self>
pub fn checked_mul(self, rhs: impl Into<Self>) -> Option<Self>
Returns None
in case of overflow (FOAR0002).
Sourcepub fn checked_div(self, rhs: impl Into<Self>) -> Option<Self>
pub fn checked_div(self, rhs: impl Into<Self>) -> Option<Self>
Sourcepub fn checked_rem(self, rhs: impl Into<Self>) -> Option<Self>
pub fn checked_rem(self, rhs: impl Into<Self>) -> Option<Self>
Sourcepub fn checked_rem_euclid(self, rhs: impl Into<Self>) -> Option<Self>
pub fn checked_rem_euclid(self, rhs: impl Into<Self>) -> Option<Self>
Sourcepub fn checked_neg(self) -> Option<Self>
pub fn checked_neg(self) -> Option<Self>
Returns None
in case of overflow (FOAR0002).
Sourcepub fn checked_abs(self) -> Option<Self>
pub fn checked_abs(self) -> Option<Self>
Sourcepub fn checked_round(self) -> Option<Self>
pub fn checked_round(self) -> Option<Self>
Sourcepub fn checked_ceil(self) -> Option<Self>
pub fn checked_ceil(self) -> Option<Self>
Returns None
in case of overflow (FOAR0002).
Sourcepub fn checked_floor(self) -> Option<Self>
pub fn checked_floor(self) -> Option<Self>
pub const fn is_negative(self) -> bool
pub const fn is_positive(self) -> bool
Sourcepub fn is_identical_with(self, other: Self) -> bool
pub fn is_identical_with(self, other: Self) -> bool
Checks if the two values are identical.
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