pub struct FixedI128(/* private fields */);
Expand description
Re-export top-level arithmetic stuff. A fixed point number representation in the range.
Fixed Point 128 bits signed, range = [-170141183460469231731.687303715884105728, 170141183460469231731.687303715884105727]
Implementations§
Source§impl FixedI128
impl FixedI128
Sourcepub const fn from_inner(inner: i128) -> FixedI128
pub const fn from_inner(inner: i128) -> FixedI128
const version of FixedPointNumber::from_inner
.
pub fn from_fraction(x: f64) -> FixedI128
pub fn to_fraction(self) -> f64
Trait Implementations§
Source§impl CheckedAdd for FixedI128
impl CheckedAdd for FixedI128
Source§impl CheckedDiv for FixedI128
impl CheckedDiv for FixedI128
Source§impl CheckedMul for FixedI128
impl CheckedMul for FixedI128
Source§impl CheckedSub for FixedI128
impl CheckedSub for FixedI128
Source§impl Decode for FixedI128
impl Decode for FixedI128
Source§fn decode<__CodecInputEdqy>(
__codec_input_edqy: &mut __CodecInputEdqy,
) -> Result<FixedI128, Error>where
__CodecInputEdqy: Input,
fn decode<__CodecInputEdqy>(
__codec_input_edqy: &mut __CodecInputEdqy,
) -> Result<FixedI128, Error>where
__CodecInputEdqy: Input,
Attempt to deserialise the value from input.
Source§impl<'de> Deserialize<'de> for FixedI128
impl<'de> Deserialize<'de> for FixedI128
Source§fn deserialize<D>(
deserializer: D,
) -> Result<FixedI128, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<FixedI128, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Encode for FixedI128
impl Encode for FixedI128
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 FixedI128
impl FixedPointNumber for FixedI128
Source§const DIV: <FixedI128 as FixedPointNumber>::Inner = {transmute(0x00000000000000000de0b6b3a7640000): <arithmetic::FixedI128 as arithmetic::FixedPointNumber>::Inner}
const DIV: <FixedI128 as FixedPointNumber>::Inner = {transmute(0x00000000000000000de0b6b3a7640000): <arithmetic::FixedI128 as arithmetic::FixedPointNumber>::Inner}
Precision of this fixed point implementation. It should be a power of
10
.Source§fn from_inner(inner: <FixedI128 as FixedPointNumber>::Inner) -> FixedI128
fn from_inner(inner: <FixedI128 as FixedPointNumber>::Inner) -> FixedI128
Builds this type from an integer number.
Source§fn into_inner(self) -> <FixedI128 as FixedPointNumber>::Inner
fn into_inner(self) -> <FixedI128 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 FixedI128where
N: FixedPointOperand,
D: FixedPointOperand,
impl<N, D> From<(N, D)> for FixedI128where
N: FixedPointOperand,
D: FixedPointOperand,
Source§impl Ord for FixedI128
impl Ord for FixedI128
Source§impl PartialOrd for FixedI128
impl PartialOrd for FixedI128
Source§impl Saturating for FixedI128
impl Saturating for FixedI128
Source§fn saturating_add(self, rhs: FixedI128) -> FixedI128
fn saturating_add(self, rhs: FixedI128) -> FixedI128
Saturating addition. Compute
self + rhs
, saturating at the numeric bounds instead of
overflowing.Source§fn saturating_sub(self, rhs: FixedI128) -> FixedI128
fn saturating_sub(self, rhs: FixedI128) -> FixedI128
Saturating subtraction. Compute
self - rhs
, saturating at the numeric bounds instead of
overflowing.Source§fn saturating_mul(self, rhs: FixedI128) -> FixedI128
fn saturating_mul(self, rhs: FixedI128) -> FixedI128
Saturating multiply. Compute
self * rhs
, saturating at the numeric bounds instead of
overflowing.Source§fn saturating_pow(self, exp: usize) -> FixedI128
fn saturating_pow(self, exp: usize) -> FixedI128
Saturating exponentiation. Compute
self.pow(exp)
, saturating at the numeric bounds
instead of overflowing.Source§impl Serialize for FixedI128
impl Serialize for FixedI128
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 FixedI128
impl EncodeLike for FixedI128
impl Eq for FixedI128
impl StructuralPartialEq for FixedI128
Auto Trait Implementations§
impl Freeze for FixedI128
impl RefUnwindSafe for FixedI128
impl Send for FixedI128
impl Sync for FixedI128
impl Unpin for FixedI128
impl UnwindSafe for FixedI128
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> 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
.