pub struct Decimal(pub U192);Expand description
Large decimal values, precise to 18 digits
Tuple Fields§
§0: U192Implementations§
Source§impl 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§
Source§impl Ord for Decimal
impl Ord for Decimal
Source§impl PartialOrd for Decimal
impl PartialOrd for Decimal
Source§impl TryDiv<Decimal> for Decimal
impl TryDiv<Decimal> for Decimal
Source§fn try_div(self, rhs: Self) -> Result<Self, ProgramError>
fn try_div(self, rhs: Self) -> Result<Self, ProgramError>
Divide
Source§impl TryMul<Decimal> for Decimal
impl TryMul<Decimal> for Decimal
Source§fn try_mul(self, rhs: Self) -> Result<Self, ProgramError>
fn try_mul(self, rhs: Self) -> Result<Self, ProgramError>
Multiply
Source§impl TrySub for Decimal
impl TrySub for Decimal
Source§fn 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 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<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