Struct oxsdatatypes::Decimal
source · 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
sourcepub fn new(i: i128, n: u32) -> Result<Self, DecimalOverflowError>
pub fn new(i: i128, n: u32) -> Result<Self, DecimalOverflowError>
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>
sourcepub fn checked_sub(&self, rhs: impl Into<Self>) -> Option<Self>
pub fn checked_sub(&self, rhs: impl Into<Self>) -> Option<Self>
sourcepub fn checked_mul(&self, rhs: impl Into<Self>) -> Option<Self>
pub fn checked_mul(&self, rhs: impl Into<Self>) -> Option<Self>
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>
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>
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.
pub const MIN: Self = _
pub const MAX: Self = _
Trait Implementations§
source§impl FromStr for Decimal
impl FromStr for Decimal
§type Err = ParseDecimalError
type Err = ParseDecimalError
The associated error which can be returned from parsing.
source§impl Ord for Decimal
impl Ord for Decimal
source§impl PartialEq<Decimal> for Decimal
impl PartialEq<Decimal> for Decimal
source§impl PartialOrd<Decimal> for Decimal
impl PartialOrd<Decimal> for Decimal
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§impl TryFrom<Decimal> for Integer
impl TryFrom<Decimal> for Integer
§type Error = DecimalOverflowError
type Error = DecimalOverflowError
The type returned in the event of a conversion error.
source§impl TryFrom<Double> for Decimal
impl TryFrom<Double> for Decimal
§type Error = DecimalOverflowError
type Error = DecimalOverflowError
The type returned in the event of a conversion error.
source§impl TryFrom<Float> for Decimal
impl TryFrom<Float> for Decimal
§type Error = DecimalOverflowError
type Error = DecimalOverflowError
The type returned in the event of a conversion error.
source§impl TryFrom<i128> for Decimal
impl TryFrom<i128> for Decimal
§type Error = DecimalOverflowError
type Error = DecimalOverflowError
The type returned in the event of a conversion error.
source§impl TryFrom<u128> for Decimal
impl TryFrom<u128> for Decimal
§type Error = DecimalOverflowError
type Error = DecimalOverflowError
The type returned in the event of a conversion error.
impl Copy for Decimal
impl Eq for Decimal
impl StructuralEq for Decimal
impl StructuralPartialEq for Decimal
Auto Trait Implementations§
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