Struct sp_arithmetic::per_things::Permill [−][src]
A fixed point representation of a number in the range [0, 1].
Parts per Million
Implementations
impl Permill
[src][−]
pub const fn from_parts(parts: u32) -> Self
[src][−]
From an explicitly defined number of parts per maximum of the type.
pub const fn from_percent(x: u32) -> Self
[src][−]
Converts a percent into Self
. Equal to x / 100
.
This can be created at compile time.
pub const fn one() -> Self
[src][−]
See PerThing::one
pub fn is_one(&self) -> bool
[src][−]
See PerThing::is_one
.
pub const fn zero() -> Self
[src][−]
See PerThing::zero
.
pub fn is_zero(&self) -> bool
[src][−]
See PerThing::is_zero
.
pub const fn deconstruct(self) -> u32
[src][−]
pub fn square(self) -> Self
[src][−]
See PerThing::square
.
pub fn from_fraction(x: f64) -> Self
[src][−]
pub fn from_rational_approximation<N>(p: N, q: N) -> Self where
N: Clone + Ord + TryInto<u32> + TryInto<u64> + Div<N, Output = N> + Rem<N, Output = N> + Add<N, Output = N> + Unsigned,
u32: Into<N>,
[src][−]
N: Clone + Ord + TryInto<u32> + TryInto<u64> + Div<N, Output = N> + Rem<N, Output = N> + Add<N, Output = N> + Unsigned,
u32: Into<N>,
pub fn mul_floor<N>(self, b: N) -> N where
N: Clone + UniqueSaturatedInto<u32> + Rem<N, Output = N> + Div<N, Output = N> + Mul<N, Output = N> + Add<N, Output = N> + Unsigned,
u32: Into<N>,
[src][−]
N: Clone + UniqueSaturatedInto<u32> + Rem<N, Output = N> + Div<N, Output = N> + Mul<N, Output = N> + Add<N, Output = N> + Unsigned,
u32: Into<N>,
See PerThing::mul_floor
.
pub fn mul_ceil<N>(self, b: N) -> N where
N: Clone + UniqueSaturatedInto<u32> + Rem<N, Output = N> + Div<N, Output = N> + Mul<N, Output = N> + Add<N, Output = N> + Unsigned,
u32: Into<N>,
[src][−]
N: Clone + UniqueSaturatedInto<u32> + Rem<N, Output = N> + Div<N, Output = N> + Mul<N, Output = N> + Add<N, Output = N> + Unsigned,
u32: Into<N>,
See PerThing::mul_ceil
.
pub fn saturating_reciprocal_mul<N>(self, b: N) -> N where
N: Clone + UniqueSaturatedInto<u32> + Rem<N, Output = N> + Div<N, Output = N> + Mul<N, Output = N> + Add<N, Output = N> + Saturating + Unsigned,
u32: Into<N>,
[src][−]
N: Clone + UniqueSaturatedInto<u32> + Rem<N, Output = N> + Div<N, Output = N> + Mul<N, Output = N> + Add<N, Output = N> + Saturating + Unsigned,
u32: Into<N>,
pub fn saturating_reciprocal_mul_floor<N>(self, b: N) -> N where
N: Clone + UniqueSaturatedInto<u32> + Rem<N, Output = N> + Div<N, Output = N> + Mul<N, Output = N> + Add<N, Output = N> + Saturating + Unsigned,
u32: Into<N>,
[src][−]
N: Clone + UniqueSaturatedInto<u32> + Rem<N, Output = N> + Div<N, Output = N> + Mul<N, Output = N> + Add<N, Output = N> + Saturating + Unsigned,
u32: Into<N>,
pub fn saturating_reciprocal_mul_ceil<N>(self, b: N) -> N where
N: Clone + UniqueSaturatedInto<u32> + Rem<N, Output = N> + Div<N, Output = N> + Mul<N, Output = N> + Add<N, Output = N> + Saturating + Unsigned,
u32: Into<N>,
[src][−]
N: Clone + UniqueSaturatedInto<u32> + Rem<N, Output = N> + Div<N, Output = N> + Mul<N, Output = N> + Add<N, Output = N> + Saturating + Unsigned,
u32: Into<N>,
impl Permill
[src][−]
pub const fn from_perthousand(x: u32) -> Self
[src][−]
Converts a percent into Self
. Equal to x / 1000
.
This can be created at compile time.
Trait Implementations
impl Bounded for Permill
[src][+]
impl Clone for Permill
[src][+]
impl CompactAs for Permill
[src][+]
type As = u32
fn encode_as(&self) -> &Self::As
[src][−]
fn decode_from(x: Self::As) -> Result<Self, Error>
[src][−]
impl Copy for Permill
[src]
impl Debug for Permill
[src][+]
impl Decode for Permill
[src][+]
impl Default for Permill
[src][+]
impl<'de> Deserialize<'de> for Permill
[src][+]
impl Div<Permill> for Permill
[src][+]
impl Encode for Permill
[src][+]
impl EncodeLike<Permill> for Permill
[src]
impl Eq for Permill
[src]
impl From<Compact<Permill>> for Permill
[src][+]
impl<N> Mul<N> for Permill where
N: Clone + UniqueSaturatedInto<u32> + Rem<N, Output = N> + Div<N, Output = N> + Mul<N, Output = N> + Add<N, Output = N> + Unsigned,
u32: Into<N>,
[src][+]
N: Clone + UniqueSaturatedInto<u32> + Rem<N, Output = N> + Div<N, Output = N> + Mul<N, Output = N> + Add<N, Output = N> + Unsigned,
u32: Into<N>,
impl Ord for Permill
[src][+]
impl PartialEq<Permill> for Permill
[src][+]
impl PartialOrd<Permill> for Permill
[src][+]
impl PerThing for Permill
[src][+]
impl Saturating for Permill
[src][+]
impl Serialize for Permill
[src][+]
impl StructuralEq for Permill
[src]
impl StructuralPartialEq for Permill
[src]
Auto Trait Implementations
impl RefUnwindSafe for Permill
impl Send for Permill
impl Sync for Permill
impl Unpin for Permill
impl UnwindSafe for Permill
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src][+]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src][+]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src][+]
T: ?Sized,
impl<S> Codec for S where
S: Decode + Encode,
[src]
S: Decode + Encode,
impl<T> DecodeAll for T where
T: Decode,
[src][+]
T: Decode,
impl<T> DecodeLimit for T where
T: Decode,
[src][+]
T: Decode,
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<'_, '_, T> EncodeLike<&'_ &'_ T> for T where
T: Encode,
[src]
T: Encode,
impl<'_, T> EncodeLike<&'_ T> for T where
T: Encode,
[src]
T: Encode,
impl<'_, T> EncodeLike<&'_ mut T> for T where
T: Encode,
[src]
T: Encode,
impl<T> EncodeLike<Arc<T>> for T where
T: Encode,
[src]
T: Encode,
impl<T> EncodeLike<Box<T, Global>> for T where
T: Encode,
[src]
T: Encode,
impl<'a, T> EncodeLike<Cow<'a, T>> for T where
T: ToOwned + Encode,
[src]
T: ToOwned + Encode,
impl<T> EncodeLike<Rc<T>> for T where
T: Encode,
[src]
T: Encode,
impl<T> From<T> for T
[src][+]
impl<S> FullCodec for S where
S: Decode + FullEncode,
[src]
S: Decode + FullEncode,
impl<S> FullEncode for S where
S: Encode + EncodeLike<S>,
[src]
S: Encode + EncodeLike<S>,
impl<T> HasCompact for T where
T: 'static,
Compact<T>: for<'a> EncodeAsRef<'a, T>,
Compact<T>: Decode,
Compact<T>: From<T>,
Compact<T>: Into<T>,
[src]
T: 'static,
Compact<T>: for<'a> EncodeAsRef<'a, T>,
Compact<T>: Decode,
Compact<T>: From<T>,
Compact<T>: Into<T>,
impl<T, U> Into<U> for T where
U: From<T>,
[src][+]
U: From<T>,
impl<T> KeyedVec for T where
T: Codec,
[src][+]
T: Codec,
impl<T> SaturatedConversion for T
[src][+]
impl<T> ToOwned for T where
T: Clone,
[src][+]
T: Clone,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src][+]
U: Into<T>,
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src][+]
U: TryFrom<T>,
impl<T, S> UniqueSaturatedFrom<T> for S where
S: TryFrom<T> + Bounded,
[src][+]
S: TryFrom<T> + Bounded,
impl<T, S> UniqueSaturatedInto<T> for S where
T: Bounded,
S: TryInto<T>,
[src][+]
T: Bounded,
S: TryInto<T>,