Struct num::rational::Ratio [] [src]

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

Represents the ratio between 2 numbers.

Methods

impl<T> Ratio<T> where T: Clone + Integer

[]

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> Ratio<T> where T: Clone + Integer + PrimInt

[]

Raises the ratio to the power of an exponent

impl Ratio<BigInt>

[]

Converts a float into a rational number.

Trait Implementations

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

The resulting type after applying the * operator

[]

The method for the * operator

impl<T> Mul<Ratio<T>> for Ratio<T> where T: Clone + Integer

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

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

The resulting type after applying the * operator

[]

The method for the * operator

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

impl<T> Sub<Ratio<T>> for Ratio<T> where T: Clone + Integer

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

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

impl<T> Signed for Ratio<T> where T: Clone + Integer + Signed

[]

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> Ord for Ratio<T> where T: Clone + Integer

impl<T> One for Ratio<T> where T: Clone + Integer

[]

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

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

impl<T> Div<Ratio<T>> for Ratio<T> where T: Clone + Integer

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

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

impl<T> Zero for Ratio<T> where T: Clone + Integer

[]

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

[]

Returns true if self is equal to the additive identity.

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

[]

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

impl<T> Decodable for Ratio<T> where T: Decodable

impl<T> Hash for Ratio<T> where T: Hash

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

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

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

impl<T> Add<Ratio<T>> for Ratio<T> where T: Clone + Integer

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

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

impl<T> PartialEq<Ratio<T>> for Ratio<T> where T: Clone + Integer

impl<T> Encodable for Ratio<T> where T: Encodable

impl<T> PartialOrd<Ratio<T>> for Ratio<T> where T: Clone + Integer

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

impl<T> Rem<Ratio<T>> for Ratio<T> where T: Clone + Integer

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

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

impl<T> FromStr for Ratio<T> where T: Clone + FromStr + Integer

[]

Parses numer/denom or just numer.

impl<T> Debug for Ratio<T> where T: Debug

impl<T> Num for Ratio<T> where T: Clone + Integer

[]

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

impl<T> Copy for Ratio<T> where T: Copy

impl<T> Eq for Ratio<T> where T: Clone + Integer

impl<T> Clone for Ratio<T> where T: Clone

[]

Returns a copy of the value. Read more

[]

Performs copy-assignment from source. Read more