[][src]Struct fixed_unsigned::FixedUnsigned

pub struct FixedUnsigned<S> where
    S: FixedScale
{ /* fields omitted */ }

A fixed point unsigned integer

This is a num_bigint::BigUint with a fixed scale.

The fixed scale is determined by the generic S which implements FixedScale and provides the constant FixedScale::SCALE.

Methods

impl<S> FixedUnsigned<S> where
    S: FixedScale
[src]

pub fn int_part(&self) -> BigUint[src]

Returns the integer part as BigUint (i.e. the part before the decimal point)

pub fn frac_part(&self) -> BigUint[src]

pub fn scale(&self) -> u64[src]

Returns the scale of the FixedUnsigned as u64.

Note that the scale is fixed by type, so for a FixedUnsigned<S> you can also get it as constant by S::Scale. This function is only for convenience.

pub fn from_bytes_be(bytes: &[u8]) -> Self[src]

pub fn from_bytes_le(bytes: &[u8]) -> Self[src]

pub fn to_bytes_be(&self) -> Vec<u8>[src]

pub fn to_bytes_le(&self) -> Vec<u8>[src]

pub fn to_radix_string(&self, radix: u8, uppercase: bool) -> String[src]

Converts the FixedUnsigned to a string representation in base radix.

Panics

This function will panic if the radix is 0 or greater than 36.

pub fn from_radix_string(string: &str, radix: u8) -> Result<Self, ParseError>[src]

Converts a string representation to a FixedUnsigned with base radix.

NOTE: This function always rounds down.

Panics

This function will panic if the radix is 0 or greater than 36.

pub fn into_biguint(self) -> BigUint[src]

Converts to a BigUint losing the decimal places

NOTE: This is not implemented as a Into/From trait to make the loss of precision implicit

pub fn into_biguint_without_scale(self) -> BigUint[src]

pub fn bits(&self) -> usize[src]

pub fn bytes(&self) -> usize[src]

pub fn into_scale<T: FixedScale, R: RoundingMode>(self) -> FixedUnsigned<T>[src]

Convert from scale S to scale T.

Trait Implementations

impl<S> From<BigUint> for FixedUnsigned<S> where
    S: FixedScale
[src]

impl<S: FixedScale> From<u64> for FixedUnsigned<S>[src]

impl<S: FixedScale> From<u32> for FixedUnsigned<S>[src]

impl<S: FixedScale> From<u16> for FixedUnsigned<S>[src]

impl<S: FixedScale> From<u8> for FixedUnsigned<S>[src]

impl<S: FixedScale> From<f64> for FixedUnsigned<S>[src]

Converts a f64 to a FixedUnsigned

impl<S: Clone> Clone for FixedUnsigned<S> where
    S: FixedScale
[src]

impl<S> Default for FixedUnsigned<S> where
    S: FixedScale
[src]

impl<S> Eq for FixedUnsigned<S> where
    S: FixedScale
[src]

impl<S> Ord for FixedUnsigned<S> where
    S: FixedScale
[src]

impl<S> PartialEq<FixedUnsigned<S>> for FixedUnsigned<S> where
    S: FixedScale
[src]

impl<S> PartialOrd<FixedUnsigned<S>> for FixedUnsigned<S> where
    S: FixedScale
[src]

impl<S> Display for FixedUnsigned<S> where
    S: FixedScale
[src]

impl<S> Debug for FixedUnsigned<S> where
    S: FixedScale
[src]

impl<S> Div<FixedUnsigned<S>> for FixedUnsigned<S> where
    S: FixedScale
[src]

type Output = Self

The resulting type after applying the / operator.

impl<'a, 'b, S> Div<&'b FixedUnsigned<S>> for &'a FixedUnsigned<S> where
    S: FixedScale
[src]

type Output = FixedUnsigned<S>

The resulting type after applying the / operator.

impl<S> Sub<FixedUnsigned<S>> for FixedUnsigned<S> where
    S: FixedScale
[src]

type Output = Self

The resulting type after applying the - operator.

impl<'a, 'b, S> Sub<&'b FixedUnsigned<S>> for &'a FixedUnsigned<S> where
    S: FixedScale
[src]

type Output = FixedUnsigned<S>

The resulting type after applying the - operator.

impl<S> FromStr for FixedUnsigned<S> where
    S: FixedScale
[src]

type Err = ParseError

The associated error which can be returned from parsing.

impl<S> Add<FixedUnsigned<S>> for FixedUnsigned<S> where
    S: FixedScale
[src]

type Output = Self

The resulting type after applying the + operator.

impl<'a, 'b, S> Add<&'b FixedUnsigned<S>> for &'a FixedUnsigned<S> where
    S: FixedScale
[src]

type Output = FixedUnsigned<S>

The resulting type after applying the + operator.

impl<S> Mul<FixedUnsigned<S>> for FixedUnsigned<S> where
    S: FixedScale
[src]

type Output = Self

The resulting type after applying the * operator.

impl<'a, 'b, S> Mul<&'b FixedUnsigned<S>> for &'a FixedUnsigned<S> where
    S: FixedScale
[src]

type Output = FixedUnsigned<S>

The resulting type after applying the * operator.

impl<S> AddAssign<FixedUnsigned<S>> for FixedUnsigned<S> where
    S: FixedScale
[src]

impl<S> SubAssign<FixedUnsigned<S>> for FixedUnsigned<S> where
    S: FixedScale
[src]

impl<S> MulAssign<FixedUnsigned<S>> for FixedUnsigned<S> where
    S: FixedScale
[src]

impl<S> DivAssign<FixedUnsigned<S>> for FixedUnsigned<S> where
    S: FixedScale
[src]

impl<S> Hash for FixedUnsigned<S> where
    S: FixedScale
[src]

impl<S> One for FixedUnsigned<S> where
    S: FixedScale
[src]

impl<S> Zero for FixedUnsigned<S> where
    S: FixedScale
[src]

Auto Trait Implementations

impl<S> Send for FixedUnsigned<S> where
    S: Send

impl<S> Sync for FixedUnsigned<S> where
    S: Sync

impl<S> Unpin for FixedUnsigned<S> where
    S: Unpin

impl<S> UnwindSafe for FixedUnsigned<S> where
    S: UnwindSafe

impl<S> RefUnwindSafe for FixedUnsigned<S> where
    S: RefUnwindSafe

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]