pub struct Decimal(pub U192);Expand description
Large decimal values, precise to 18 digits
Tuple Fields
0: U192Implementations
sourceimpl Decimal
impl Decimal
sourcepub fn from_percent(percent: u8) -> Self
pub fn from_percent(percent: u8) -> Self
Create scaled decimal from percent value
sourcepub fn to_scaled_val(&self) -> Result<u128, ProgramError>
pub fn to_scaled_val(&self) -> Result<u128, ProgramError>
Return raw scaled value if it fits within u128
sourcepub fn from_scaled_val(scaled_val: u128) -> Self
pub fn from_scaled_val(scaled_val: u128) -> Self
Create decimal from scaled value
sourcepub fn try_round_u64(&self) -> Result<u64, ProgramError>
pub fn try_round_u64(&self) -> Result<u64, ProgramError>
Round scaled decimal to u64
sourcepub fn try_ceil_u64(&self) -> Result<u64, ProgramError>
pub fn try_ceil_u64(&self) -> Result<u64, ProgramError>
Ceiling scaled decimal to u64
sourcepub fn try_floor_u64(&self) -> Result<u64, ProgramError>
pub fn try_floor_u64(&self) -> Result<u64, ProgramError>
Floor scaled decimal to u64
Trait Implementations
sourceimpl Ord for Decimal
impl Ord for Decimal
1.21.0 · sourcefn max(self, other: Self) -> Self
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
1.21.0 · sourcefn min(self, other: Self) -> Self
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl PartialOrd<Decimal> for Decimal
impl PartialOrd<Decimal> for Decimal
sourcefn partial_cmp(&self, other: &Decimal) -> Option<Ordering>
fn partial_cmp(&self, other: &Decimal) -> Option<Ordering>
1.0.0 · sourcefn 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 moresourceimpl TryDiv<Decimal> for Decimal
impl TryDiv<Decimal> for Decimal
sourcefn try_div(self, rhs: Self) -> Result<Self, ProgramError>
fn try_div(self, rhs: Self) -> Result<Self, ProgramError>
Divide
sourceimpl TryDiv<Rate> for Decimal
impl TryDiv<Rate> for Decimal
sourcefn try_div(self, rhs: Rate) -> Result<Self, ProgramError>
fn try_div(self, rhs: Rate) -> Result<Self, ProgramError>
Divide
sourceimpl TryDiv<u64> for Decimal
impl TryDiv<u64> for Decimal
sourcefn try_div(self, rhs: u64) -> Result<Self, ProgramError>
fn try_div(self, rhs: u64) -> Result<Self, ProgramError>
Divide
sourceimpl TryMul<Decimal> for Decimal
impl TryMul<Decimal> for Decimal
sourcefn try_mul(self, rhs: Self) -> Result<Self, ProgramError>
fn try_mul(self, rhs: Self) -> Result<Self, ProgramError>
Multiply
sourceimpl TryMul<Rate> for Decimal
impl TryMul<Rate> for Decimal
sourcefn try_mul(self, rhs: Rate) -> Result<Self, ProgramError>
fn try_mul(self, rhs: Rate) -> Result<Self, ProgramError>
Multiply
sourceimpl TryMul<u64> for Decimal
impl TryMul<u64> for Decimal
sourcefn try_mul(self, rhs: u64) -> Result<Self, ProgramError>
fn try_mul(self, rhs: u64) -> Result<Self, ProgramError>
Multiply
sourceimpl TrySub for Decimal
impl TrySub for Decimal
sourcefn try_sub(self, rhs: Self) -> Result<Self, ProgramError>
fn try_sub(self, rhs: Self) -> Result<Self, ProgramError>
Subtract
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
impl<T> AbiExample for T
impl<T> AbiExample for T
default fn example() -> T
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more