Struct spl_token_bonding::precise_number::PreciseNumber
source · [−]pub struct PreciseNumber {
pub value: InnerUint,
}Expand description
Struct encapsulating a fixed-point number that allows for decimal calculations
Fields
value: InnerUintWrapper over the inner value, which is multiplied by ONE
Implementations
sourceimpl PreciseNumber
impl PreciseNumber
pub fn signed(&self) -> SignedPreciseNumber
pub fn zero() -> Self
pub fn one() -> Self
sourcepub fn new(value: u128) -> Option<Self>
pub fn new(value: u128) -> Option<Self>
Create a precise number from an imprecise u128, should always succeed
sourcepub fn to_imprecise(&self) -> Option<u128>
pub fn to_imprecise(&self) -> Option<u128>
Convert a precise number back to u128
sourcepub fn almost_eq(&self, rhs: &Self, precision: InnerUint) -> bool
pub fn almost_eq(&self, rhs: &Self, precision: InnerUint) -> bool
Checks that two PreciseNumbers are equal within some tolerance
sourcepub fn greater_than(&self, rhs: &Self) -> bool
pub fn greater_than(&self, rhs: &Self) -> bool
Checks that a number is greater than another
sourcepub fn less_than_or_equal(&self, rhs: &Self) -> bool
pub fn less_than_or_equal(&self, rhs: &Self) -> bool
Checks that a number is less than another
sourcepub fn greater_than_or_equal(&self, rhs: &Self) -> bool
pub fn greater_than_or_equal(&self, rhs: &Self) -> bool
Checks that a number is greater than another
sourcepub fn checked_div(&self, rhs: &Self) -> Option<Self>
pub fn checked_div(&self, rhs: &Self) -> Option<Self>
Performs a checked division on two precise numbers
sourcepub fn checked_mul(&self, rhs: &Self) -> Option<Self>
pub fn checked_mul(&self, rhs: &Self) -> Option<Self>
Performs a multiplication on two precise numbers
sourcepub fn checked_add(&self, rhs: &Self) -> Option<Self>
pub fn checked_add(&self, rhs: &Self) -> Option<Self>
Performs addition of two precise numbers
sourcepub fn checked_sub(&self, rhs: &Self) -> Option<Self>
pub fn checked_sub(&self, rhs: &Self) -> Option<Self>
Subtracts the argument from self
pub fn unsigned_sub(&self, rhs: &Self) -> (Self, bool)
pub fn log(&self) -> Option<SignedPreciseNumber>
pub fn pow(&self, exp: &Self) -> Option<Self>
pub fn print(&self)
Trait Implementations
sourceimpl Clone for PreciseNumber
impl Clone for PreciseNumber
sourcefn clone(&self) -> PreciseNumber
fn clone(&self) -> PreciseNumber
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read more
sourceimpl Debug for PreciseNumber
impl Debug for PreciseNumber
sourceimpl OrArithError<PreciseNumber> for Option<PreciseNumber>
impl OrArithError<PreciseNumber> for Option<PreciseNumber>
fn or_arith_error(self) -> Result<PreciseNumber>
sourceimpl PartialEq<PreciseNumber> for PreciseNumber
impl PartialEq<PreciseNumber> for PreciseNumber
sourcefn eq(&self, other: &PreciseNumber) -> bool
fn eq(&self, other: &PreciseNumber) -> bool
This method tests for self and other values to be equal, and is used
by ==. Read more
sourcefn ne(&self, other: &PreciseNumber) -> bool
fn ne(&self, other: &PreciseNumber) -> bool
This method tests for !=.
impl StructuralPartialEq for PreciseNumber
Auto Trait Implementations
impl RefUnwindSafe for PreciseNumber
impl Send for PreciseNumber
impl Sync for PreciseNumber
impl Unpin for PreciseNumber
impl UnwindSafe for PreciseNumber
Blanket Implementations
impl<T> AbiExample for T
impl<T> AbiExample for T
default fn example() -> T
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
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
impl<T> Pointable for T
impl<T> Pointable for T
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more