Struct num_rational::Ratio [] [src]

pub struct Ratio<T> { /* fields omitted */ }

Represents the ratio between 2 numbers.

Methods

impl<T: Clone + Integer> Ratio<T>
[src]

Creates a ratio representing the integer t.

Creates a ratio without checking for denom == 0 or reducing.

Create a new Ratio. Fails if denom == 0.

Converts to an integer.

Gets an immutable reference to the numerator.

Gets an immutable reference to the denominator.

Returns true if the rational number is an integer (denominator is 1).

Returns a reduced copy of self.

Returns the reciprocal.

Rounds towards minus infinity.

Rounds towards plus infinity.

Rounds to the nearest integer. Rounds half-way cases away from zero.

Rounds towards zero.

Returns the fractional part of a number.

impl<T: Clone + Integer + PrimInt> Ratio<T>
[src]

Raises the ratio to the power of an exponent

impl Ratio<BigInt>
[src]

Converts a float into a rational number.

Trait Implementations

impl<T: Encodable> Encodable for Ratio<T>
[src]

impl<T: Decodable> Decodable for Ratio<T>
[src]

impl<T: Copy> Copy for Ratio<T>
[src]

impl<T: Clone> Clone for Ratio<T>
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl<T: Hash> Hash for Ratio<T>
[src]

Feeds this value into the state given, updating the hasher as necessary.

Feeds a slice of this type into the state provided.

impl<T: Debug> Debug for Ratio<T>
[src]

Formats the value using the given formatter.

impl<T: Clone + Integer> Ord for Ratio<T>
[src]

This method returns an Ordering between self and other. Read more

impl<T: Clone + Integer> PartialOrd for Ratio<T>
[src]

This method returns an ordering between self and other values if one exists. Read more

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

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

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

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

impl<T: Clone + Integer> PartialEq for Ratio<T>
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl<T: Clone + Integer> Eq for Ratio<T>
[src]

impl<T: Clone + Integer> Mul<Ratio<T>> for Ratio<T>
[src]

The resulting type after applying the * operator

The method for the * operator

impl<'a, T> Mul<Ratio<T>> for &'a Ratio<T> where T: Clone + Integer
[src]

The resulting type after applying the * operator

The method for the * operator

impl<'a, T> Mul<&'a Ratio<T>> for Ratio<T> where T: Clone + Integer
[src]

The resulting type after applying the * operator

The method for the * operator

impl<'a, 'b, T> Mul<&'b Ratio<T>> for &'a Ratio<T> where T: Clone + Integer
[src]

The resulting type after applying the * operator

The method for the * operator

impl<T: Clone + Integer> Div<Ratio<T>> for Ratio<T>
[src]

The resulting type after applying the / operator

The method for the / operator

impl<'a, T> Div<Ratio<T>> for &'a Ratio<T> where T: Clone + Integer
[src]

The resulting type after applying the / operator

The method for the / operator

impl<'a, T> Div<&'a Ratio<T>> for Ratio<T> where T: Clone + Integer
[src]

The resulting type after applying the / operator

The method for the / operator

impl<'a, 'b, T> Div<&'b Ratio<T>> for &'a Ratio<T> where T: Clone + Integer
[src]

The resulting type after applying the / operator

The method for the / operator

impl<T: Clone + Integer> Add<Ratio<T>> for Ratio<T>
[src]

The resulting type after applying the + operator

The method for the + operator

impl<'a, T> Add<Ratio<T>> for &'a Ratio<T> where T: Clone + Integer
[src]

The resulting type after applying the + operator

The method for the + operator

impl<'a, T> Add<&'a Ratio<T>> for Ratio<T> where T: Clone + Integer
[src]

The resulting type after applying the + operator

The method for the + operator

impl<'a, 'b, T: Clone + Integer> Add<&'b Ratio<T>> for &'a Ratio<T>
[src]

The resulting type after applying the + operator

The method for the + operator

impl<T: Clone + Integer> Sub<Ratio<T>> for Ratio<T>
[src]

The resulting type after applying the - operator

The method for the - operator

impl<'a, T> Sub<Ratio<T>> for &'a Ratio<T> where T: Clone + Integer
[src]

The resulting type after applying the - operator

The method for the - operator

impl<'a, T> Sub<&'a Ratio<T>> for Ratio<T> where T: Clone + Integer
[src]

The resulting type after applying the - operator

The method for the - operator

impl<'a, 'b, T: Clone + Integer> Sub<&'b Ratio<T>> for &'a Ratio<T>
[src]

The resulting type after applying the - operator

The method for the - operator

impl<T: Clone + Integer> Rem<Ratio<T>> for Ratio<T>
[src]

The resulting type after applying the % operator

The method for the % operator

impl<'a, T> Rem<Ratio<T>> for &'a Ratio<T> where T: Clone + Integer
[src]

The resulting type after applying the % operator

The method for the % operator

impl<'a, T> Rem<&'a Ratio<T>> for Ratio<T> where T: Clone + Integer
[src]

The resulting type after applying the % operator

The method for the % operator

impl<'a, 'b, T: Clone + Integer> Rem<&'b Ratio<T>> for &'a Ratio<T>
[src]

The resulting type after applying the % operator

The method for the % operator

impl<T> Neg for Ratio<T> where T: Clone + Integer + Neg<Output=T>
[src]

The resulting type after applying the - operator

The method for the unary - operator

impl<'a, T> Neg for &'a Ratio<T> where T: Clone + Integer + Neg<Output=T>
[src]

The resulting type after applying the - operator

The method for the unary - operator

impl<T: Clone + Integer> Zero for Ratio<T>
[src]

Returns the additive identity element of Self, 0. Read more

Returns true if self is equal to the additive identity.

impl<T: Clone + Integer> One for Ratio<T>
[src]

Returns the multiplicative identity element of Self, 1. Read more

impl<T: Clone + Integer> Num for Ratio<T>
[src]

Parses numer/denom where the numbers are in base radix.

impl<T: Clone + Integer + Signed> Signed for Ratio<T>
[src]

Computes the absolute value. Read more

The positive difference of two numbers. Read more

Returns the sign of the number. Read more

Returns true if the number is positive and false if the number is zero or negative.

Returns true if the number is negative and false if the number is zero or positive.

impl<T> Display for Ratio<T> where T: Display + Eq + One
[src]

Renders as numer/denom. If denom=1, renders as numer.

impl<T: FromStr + Clone + Integer> FromStr for Ratio<T>
[src]

The associated error which can be returned from parsing.

Parses numer/denom or just numer.