pub struct FixedU128(/* private fields */);
Expand description
Re-export top-level arithmetic stuff. A fixed point number representation in the range.
Fixed Point 128 bits unsigned, range = [0.000000000000000000, 340282366920938463463.374607431768211455]
Implementations§
Source§impl FixedU128
impl FixedU128
Sourcepub const fn from_inner(inner: u128) -> FixedU128
pub const fn from_inner(inner: u128) -> FixedU128
const version of FixedPointNumber::from_inner
.
pub fn from_fraction(x: f64) -> FixedU128
pub fn to_fraction(self) -> f64
Trait Implementations§
Source§impl CheckedAdd for FixedU128
impl CheckedAdd for FixedU128
Source§impl CheckedDiv for FixedU128
impl CheckedDiv for FixedU128
Source§impl CheckedMul for FixedU128
impl CheckedMul for FixedU128
Source§impl CheckedSub for FixedU128
impl CheckedSub for FixedU128
Source§impl Decode for FixedU128
impl Decode for FixedU128
Source§fn decode<__CodecInputEdqy>(
__codec_input_edqy: &mut __CodecInputEdqy,
) -> Result<FixedU128, Error>where
__CodecInputEdqy: Input,
fn decode<__CodecInputEdqy>(
__codec_input_edqy: &mut __CodecInputEdqy,
) -> Result<FixedU128, Error>where
__CodecInputEdqy: Input,
Attempt to deserialise the value from input.
Source§impl<'de> Deserialize<'de> for FixedU128
impl<'de> Deserialize<'de> for FixedU128
Source§fn deserialize<D>(
deserializer: D,
) -> Result<FixedU128, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<FixedU128, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Encode for FixedU128
impl Encode for FixedU128
Source§fn encode_to<__CodecOutputEdqy>(
&self,
__codec_dest_edqy: &mut __CodecOutputEdqy,
)
fn encode_to<__CodecOutputEdqy>( &self, __codec_dest_edqy: &mut __CodecOutputEdqy, )
Convert self to a slice and append it to the destination.
Source§fn using_encoded<R, F>(&self, f: F) -> R
fn using_encoded<R, F>(&self, f: F) -> R
Convert self to a slice and then invoke the given closure with it.
Source§fn size_hint(&self) -> usize
fn size_hint(&self) -> usize
If possible give a hint of expected size of the encoding. Read more
Source§fn encoded_size(&self) -> usize
fn encoded_size(&self) -> usize
Calculates the encoded size. Read more
Source§impl FixedPointNumber for FixedU128
impl FixedPointNumber for FixedU128
Source§const DIV: <FixedU128 as FixedPointNumber>::Inner = {transmute(0x00000000000000000de0b6b3a7640000): <arithmetic::FixedU128 as arithmetic::FixedPointNumber>::Inner}
const DIV: <FixedU128 as FixedPointNumber>::Inner = {transmute(0x00000000000000000de0b6b3a7640000): <arithmetic::FixedU128 as arithmetic::FixedPointNumber>::Inner}
Precision of this fixed point implementation. It should be a power of
10
.Source§fn from_inner(inner: <FixedU128 as FixedPointNumber>::Inner) -> FixedU128
fn from_inner(inner: <FixedU128 as FixedPointNumber>::Inner) -> FixedU128
Builds this type from an integer number.
Source§fn into_inner(self) -> <FixedU128 as FixedPointNumber>::Inner
fn into_inner(self) -> <FixedU128 as FixedPointNumber>::Inner
Consumes
self
and returns the inner raw value.Source§fn saturating_from_integer<N>(int: N) -> Selfwhere
N: FixedPointOperand,
fn saturating_from_integer<N>(int: N) -> Selfwhere
N: FixedPointOperand,
Creates self from an integer number
int
. Read moreSource§fn checked_from_integer(int: Self::Inner) -> Option<Self>
fn checked_from_integer(int: Self::Inner) -> Option<Self>
Source§fn saturating_from_rational<N, D>(n: N, d: D) -> Selfwhere
N: FixedPointOperand,
D: FixedPointOperand,
fn saturating_from_rational<N, D>(n: N, d: D) -> Selfwhere
N: FixedPointOperand,
D: FixedPointOperand,
Source§fn checked_from_rational<N, D>(n: N, d: D) -> Option<Self>where
N: FixedPointOperand,
D: FixedPointOperand,
fn checked_from_rational<N, D>(n: N, d: D) -> Option<Self>where
N: FixedPointOperand,
D: FixedPointOperand,
Source§fn checked_mul_int<N>(self, n: N) -> Option<N>where
N: FixedPointOperand,
fn checked_mul_int<N>(self, n: N) -> Option<N>where
N: FixedPointOperand,
Source§fn saturating_mul_int<N>(self, n: N) -> Nwhere
N: FixedPointOperand,
fn saturating_mul_int<N>(self, n: N) -> Nwhere
N: FixedPointOperand,
Source§fn checked_div_int<N>(self, d: N) -> Option<N>where
N: FixedPointOperand,
fn checked_div_int<N>(self, d: N) -> Option<N>where
N: FixedPointOperand,
Source§fn saturating_div_int<N>(self, d: N) -> Nwhere
N: FixedPointOperand,
fn saturating_div_int<N>(self, d: N) -> Nwhere
N: FixedPointOperand,
Source§fn saturating_mul_acc_int<N>(self, n: N) -> Nwhere
N: FixedPointOperand,
fn saturating_mul_acc_int<N>(self, n: N) -> Nwhere
N: FixedPointOperand,
Saturating multiplication for integer type
N
, adding the result back.
Equal to self * n + n
. Read moreSource§fn saturating_abs(self) -> Self
fn saturating_abs(self) -> Self
Saturating absolute value. Read more
Source§fn reciprocal(self) -> Option<Self>
fn reciprocal(self) -> Option<Self>
Takes the reciprocal (inverse). Equal to
1 / self
. Read moreSource§fn is_positive(self) -> bool
fn is_positive(self) -> bool
Returns
true
if self
is positive and false
if the number is zero or negative.Source§fn is_negative(self) -> bool
fn is_negative(self) -> bool
Returns
true
if self
is negative and false
if the number is zero or positive.Source§impl<N, D> From<(N, D)> for FixedU128where
N: FixedPointOperand,
D: FixedPointOperand,
impl<N, D> From<(N, D)> for FixedU128where
N: FixedPointOperand,
D: FixedPointOperand,
Source§impl Ord for FixedU128
impl Ord for FixedU128
Source§impl PartialOrd for FixedU128
impl PartialOrd for FixedU128
Source§impl Saturating for FixedU128
impl Saturating for FixedU128
Source§fn saturating_add(self, rhs: FixedU128) -> FixedU128
fn saturating_add(self, rhs: FixedU128) -> FixedU128
Saturating addition. Compute
self + rhs
, saturating at the numeric bounds instead of
overflowing.Source§fn saturating_sub(self, rhs: FixedU128) -> FixedU128
fn saturating_sub(self, rhs: FixedU128) -> FixedU128
Saturating subtraction. Compute
self - rhs
, saturating at the numeric bounds instead of
overflowing.Source§fn saturating_mul(self, rhs: FixedU128) -> FixedU128
fn saturating_mul(self, rhs: FixedU128) -> FixedU128
Saturating multiply. Compute
self * rhs
, saturating at the numeric bounds instead of
overflowing.Source§fn saturating_pow(self, exp: usize) -> FixedU128
fn saturating_pow(self, exp: usize) -> FixedU128
Saturating exponentiation. Compute
self.pow(exp)
, saturating at the numeric bounds
instead of overflowing.Source§impl Serialize for FixedU128
impl Serialize for FixedU128
Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl Copy for FixedU128
impl EncodeLike for FixedU128
impl Eq for FixedU128
impl StructuralPartialEq for FixedU128
Auto Trait Implementations§
impl Freeze for FixedU128
impl RefUnwindSafe for FixedU128
impl Send for FixedU128
impl Sync for FixedU128
impl Unpin for FixedU128
impl UnwindSafe for FixedU128
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> CheckedConversion for T
impl<T> CheckedConversion for T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> DecodeLimit for Twhere
T: Decode,
impl<T> DecodeLimit for Twhere
T: Decode,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> HasCompact for T
impl<T> HasCompact for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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 moreSource§impl<T, Outer> IsWrappedBy<Outer> for T
impl<T, Outer> IsWrappedBy<Outer> for T
Source§impl<T> LowerBounded for Twhere
T: Bounded,
impl<T> LowerBounded for Twhere
T: Bounded,
Source§impl<T> SaturatedConversion for T
impl<T> SaturatedConversion for T
Source§fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
Source§fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
Consume self to return an equivalent value of
T
. Read moreSource§impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
Source§fn unchecked_into(self) -> T
fn unchecked_into(self) -> T
The counterpart to
unchecked_from
.Source§impl<T, S> UniqueSaturatedFrom<T> for S
impl<T, S> UniqueSaturatedFrom<T> for S
Source§fn unique_saturated_from(t: T) -> S
fn unique_saturated_from(t: T) -> S
Convert from a value of
T
into an equivalent instance of Self
.Source§impl<T, S> UniqueSaturatedInto<T> for S
impl<T, S> UniqueSaturatedInto<T> for S
Source§fn unique_saturated_into(self) -> T
fn unique_saturated_into(self) -> T
Consume self to return an equivalent value of
T
.