pub struct IFixed(/* private fields */);
Implementations§
Source§impl IFixed
impl IFixed
pub const DECIMALS: u8 = 18u8
Sourcepub fn try_into_balance_with_scaling(
self,
scaling_factor: U256,
) -> Result<u64, Error>
pub fn try_into_balance_with_scaling( self, scaling_factor: U256, ) -> Result<u64, Error>
Create an u64
from a IFixed
applying the specified scaling factor.
Sourcepub fn from_balance_with_scaling(balance: u64, scaling_factor: U256) -> Self
pub fn from_balance_with_scaling(balance: u64, scaling_factor: U256) -> Self
Create an IFixed
from a u64
applying the specified scaling factor.
Sourcepub fn from_raw_str(ifixed_string: &str) -> Result<Self, Error>
pub fn from_raw_str(ifixed_string: &str) -> Result<Self, Error>
Create an IFixed
from a str
containing the
ifixed internal representation.
Example: the str
containing “134850000000000000000” is
converted to the value 134.85 in IFixed.
Sourcepub const fn from_inner(inner: I256) -> Self
pub const fn from_inner(inner: I256) -> Self
Create an IFixed
using its internal representation
pub fn round_to_decimals(self, decimals: u32, round_up: bool) -> Self
pub const fn into_inner(self) -> I256
pub fn is_neg(&self) -> bool
pub fn one() -> Self
pub const fn zero() -> Self
pub fn abs(self) -> Self
pub fn uabs(self) -> Fixed
pub fn copy_sign(self, other: &Self) -> Self
Trait Implementations§
Source§impl AddAssign for IFixed
impl AddAssign for IFixed
Source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
Performs the
+=
operation. Read moreSource§impl<'de> Deserialize<'de> for IFixed
impl<'de> Deserialize<'de> for IFixed
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl DivAssign for IFixed
impl DivAssign for IFixed
Source§fn div_assign(&mut self, rhs: Self)
fn div_assign(&mut self, rhs: Self)
Performs the
/=
operation. Read moreSource§impl MulAssign for IFixed
impl MulAssign for IFixed
Source§fn mul_assign(&mut self, rhs: Self)
fn mul_assign(&mut self, rhs: Self)
Performs the
*=
operation. Read moreSource§impl Ord for IFixed
impl Ord for IFixed
Source§impl PartialOrd for IFixed
impl PartialOrd for IFixed
Source§impl Rem for IFixed
The remainder from the division of two fixed, inspired by the primitive floats implementations.
impl Rem for IFixed
The remainder from the division of two fixed, inspired by the primitive floats implementations.
The remainder has the same sign as the dividend and is computed as:
x - (x / y).trunc() * y
.
§Examples
let x: IFixed = 50.50.try_into().unwrap();
let y: IFixed = 8.125.try_into().unwrap();
let remainder = x - (x / y).trunc() * y;
assert_eq!(x % y, IFixed::try_from(1.75).unwrap());
Source§impl RemAssign for IFixed
impl RemAssign for IFixed
Source§fn rem_assign(&mut self, rhs: Self)
fn rem_assign(&mut self, rhs: Self)
Performs the
%=
operation. Read moreSource§impl SubAssign for IFixed
impl SubAssign for IFixed
Source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
Performs the
-=
operation. Read moreimpl Copy for IFixed
impl Eq for IFixed
impl StructuralPartialEq for IFixed
Auto Trait Implementations§
impl Freeze for IFixed
impl RefUnwindSafe for IFixed
impl Send for IFixed
impl Sync for IFixed
impl Unpin for IFixed
impl UnwindSafe for IFixed
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