[][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> PartialEq<FixedUnsigned<S>> for FixedUnsigned<S> where
    S: FixedScale
[src]

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests for !=.

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]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

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

fn max(self, other: Self) -> Self1.21.0[src]

Compares and returns the maximum of two values. Read more

fn min(self, other: Self) -> Self1.21.0[src]

Compares and returns the minimum of two values. Read more

fn clamp(self, min: Self, max: Self) -> Self[src]

🔬 This is a nightly-only experimental API. (clamp)

Restrict a value to a certain interval. Read more

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

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

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

#[must_use]
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests less than (for self and other) and is used by the < operator. Read more

#[must_use]
fn le(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

#[must_use]
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests greater than (for self and other) and is used by the > operator. Read more

#[must_use]
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

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

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

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> 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> 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> 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> 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]

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0[src]

Feeds a slice of this type into the given [Hasher]. Read more

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

fn set_zero(&mut self)[src]

Sets self to the additive identity element of Self, 0.

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

fn set_one(&mut self)[src]

Sets self to the multiplicative identity element of Self, 1.

fn is_one(&self) -> bool where
    Self: PartialEq<Self>, 
[src]

Returns true if self is equal to the multiplicative identity. Read more

Auto Trait Implementations

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

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

Blanket Implementations

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> Into<U> for T where
    U: From<T>, 
[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]