[][src]Trait orml_utilities::fixed_u128::FixedUnsignedNumber

pub trait FixedUnsignedNumber: Sized + Copy + Default + Debug + Saturating + Bounded + Eq + PartialEq + Ord + PartialOrd + CheckedSub + CheckedAdd + CheckedMul + CheckedDiv + Add + Sub + Div + Mul + Zero + One {
    type Inner: Debug + One + CheckedMul + CheckedDiv + FixedPointOperand + Into<U256> + Into<u128>;

    const DIV: Self::Inner;

    fn from_natural(int: Self::Inner) -> Self;
fn from_inner(int: Self::Inner) -> Self;
fn into_inner(self) -> Self::Inner; fn accuracy() -> Self::Inner { ... }
fn saturating_from_integer<N: UniqueSaturatedInto<Self::Inner> + PartialOrd + Zero>(
        int: N
    ) -> Self { ... }
fn checked_from_integer(int: Self::Inner) -> Option<Self> { ... }
fn saturating_from_rational<N: FixedPointOperand, D: FixedPointOperand>(
        n: N,
        d: D
    ) -> Self { ... }
fn checked_from_rational<N: FixedPointOperand, D: FixedPointOperand>(
        n: N,
        d: D
    ) -> Option<Self> { ... }
fn checked_mul_int<N: FixedPointOperand>(&self, other: N) -> Option<N> { ... }
fn saturating_mul_int<N: FixedPointOperand>(self, n: N) -> N { ... }
fn checked_div_int<N: FixedPointOperand>(&self, other: N) -> Option<N> { ... }
fn saturating_div_int<N: FixedPointOperand>(self, d: N) -> N { ... }
fn saturating_mul_acc_int<N: FixedPointOperand>(self, n: N) -> N { ... }
fn reciprocal(self) -> Option<Self> { ... }
fn trunc(self) -> Self { ... }
fn frac(self) -> Self { ... }
fn ceil(self) -> Self { ... }
fn floor(self) -> Self { ... }
fn round(self) -> Self { ... } }

Associated Types

Loading content...

Associated Constants

const DIV: Self::Inner

Precision of this fixed point implementation. It should be a power of 10.

Loading content...

Required methods

fn from_natural(int: Self::Inner) -> Self

Create self from a natural number.

Note that this might be lossy.

fn from_inner(int: Self::Inner) -> Self

Builds this type from an integer number.

fn into_inner(self) -> Self::Inner

Consumes self and returns the inner raw value.

Loading content...

Provided methods

fn accuracy() -> Self::Inner

Precision of this fixed point implementation.

fn saturating_from_integer<N: UniqueSaturatedInto<Self::Inner> + PartialOrd + Zero>(
    int: N
) -> Self

Creates self from an integer number int.

Returns Self::max or Self::min if int exceeds accuracy.

fn checked_from_integer(int: Self::Inner) -> Option<Self>

Creates self from an integer number int.

Returns None if int exceeds accuracy.

fn saturating_from_rational<N: FixedPointOperand, D: FixedPointOperand>(
    n: N,
    d: D
) -> Self

Creates self from a rational number. Equal to n / d.

Panics if d = 0. Returns Self::max or Self::min if n / d exceeds accuracy.

fn checked_from_rational<N: FixedPointOperand, D: FixedPointOperand>(
    n: N,
    d: D
) -> Option<Self>

Creates self from a rational number. Equal to n / d.

Returns None if d == 0 or n / d exceeds accuracy.

fn checked_mul_int<N: FixedPointOperand>(&self, other: N) -> Option<N>

Checked mul for int type N. Equal to self * n.

Returns None if the result does not fit in N.

fn saturating_mul_int<N: FixedPointOperand>(self, n: N) -> N

Saturating multiplication for integer type N. Equal to self * n.

Returns N::min or N::max if the result does not fit in N.

fn checked_div_int<N: FixedPointOperand>(&self, other: N) -> Option<N>

Checked division for integer type N. Equal to self / d.

Returns None if the result does not fit in N or d == 0.

fn saturating_div_int<N: FixedPointOperand>(self, d: N) -> N

Saturating division for integer type N. Equal to self / d.

Panics if d == 0. Returns N::min or N::max if the result does not fit in N.

fn saturating_mul_acc_int<N: FixedPointOperand>(self, n: N) -> N

Saturating multiplication for integer type N, adding the result back. Equal to self * n + n.

Returns N::min or N::max if the multiplication or final result does not fit in N.

fn reciprocal(self) -> Option<Self>

Takes the reciprocal (inverse). Equal to 1 / self.

Returns None if self = 0.

fn trunc(self) -> Self

Returns the integer part.

fn frac(self) -> Self

Returns the fractional part.

Note: the returned fraction will be non-negative for negative numbers, except in the case where the integer part is zero.

fn ceil(self) -> Self

Returns the smallest integer greater than or equal to a number.

Saturates to Self::max (truncated) if the result does not fit.

fn floor(self) -> Self

Returns the largest integer less than or equal to a number.

Saturates to Self::min (truncated) if the result does not fit.

fn round(self) -> Self

Returns the number rounded to the nearest integer. Rounds half-way cases away from 0.0.

Saturates to Self::min or Self::max (truncated) if the result does not fit.

Loading content...

Implementors

impl FixedUnsignedNumber for FixedU128[src]

type Inner = u128

Loading content...