Rational numbers

Type BigRational

type BigRational = Ratio<BigInt>

Alias for arbitrary precision rationals.

Type Rational

type Rational = Ratio<int>

Alias for a Ratio of machine-sized integers.

Type Rational32

type Rational32 = Ratio<i32>

Type Rational64

type Rational64 = Ratio<i64>

Struct Ratio

pub struct Ratio<T> {
    numer: T,
    denom: T,
}

Represents the ratio between 2 numbers.

Implementation of ::std::clone::Clone for Ratio<T> where <T: ::std::clone::Clone>

Automatically derived.

Method clone

fn clone(&self) -> Ratio<T>

Implementation for Ratio<T> where <T: Clone + Integer + Ord>

Method from_integer

fn from_integer(t: T) -> Ratio<T>

Create a ratio representing the integer t.

Method new_raw

fn new_raw(numer: T, denom: T) -> Ratio<T>

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

Method new

fn new(numer: T, denom: T) -> Ratio<T>

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

Implementation of Eq for Ratio<T> where <T: Mul<T, T> + Eq>

Method eq

fn eq(&self, other: &Ratio<T>) -> bool

Method ne

fn ne(&self, other: &Ratio<T>) -> bool

Implementation of TotalEq for Ratio<T> where <T: Mul<T, T> + TotalEq>

Method equals

fn equals(&self, other: &Ratio<T>) -> bool

Implementation of Ord for Ratio<T> where <T: Mul<T, T> + Ord>

Method lt

fn lt(&self, other: &Ratio<T>) -> bool

Method gt

fn gt(&self, other: &Ratio<T>) -> bool

Method le

fn le(&self, other: &Ratio<T>) -> bool

Method ge

fn ge(&self, other: &Ratio<T>) -> bool

Implementation of TotalOrd for Ratio<T> where <T: Mul<T, T> + TotalOrd>

Method cmp

fn cmp(&self, other: &Ratio<T>) -> cmp::Ordering

Implementation of Mul<Ratio<T>, Ratio<T>> for Ratio<T> where <T: Clone + Integer + Ord>

Method mul

fn mul(&self, rhs: &Ratio<T>) -> Ratio<T>

Implementation of Div<Ratio<T>, Ratio<T>> for Ratio<T> where <T: Clone + Integer + Ord>

Method div

fn div(&self, rhs: &Ratio<T>) -> Ratio<T>

Implementation of Add<Ratio<T>, Ratio<T>> for Ratio<T> where <T: Clone + Integer + Ord>

Method add

fn add(&self, rhs: &Ratio<T>) -> Ratio<T>

Implementation of Sub<Ratio<T>, Ratio<T>> for Ratio<T> where <T: Clone + Integer + Ord>

Method sub

fn sub(&self, rhs: &Ratio<T>) -> Ratio<T>

Implementation of Rem<Ratio<T>, Ratio<T>> for Ratio<T> where <T: Clone + Integer + Ord>

Method rem

fn rem(&self, rhs: &Ratio<T>) -> Ratio<T>

Implementation of Neg<Ratio<T>> for Ratio<T> where <T: Clone + Integer + Ord>

Method neg

fn neg(&self) -> Ratio<T>

Implementation of Zero for Ratio<T> where <T: Clone + Integer + Ord>

Method zero

fn zero() -> Ratio<T>

Method is_zero

fn is_zero(&self) -> bool

Implementation of One for Ratio<T> where <T: Clone + Integer + Ord>

Method one

fn one() -> Ratio<T>

Implementation of Num for Ratio<T> where <T: Clone + Integer + Ord>

Implementation of Round for Ratio<T> where <T: Clone + Integer + Ord>

Method floor

fn floor(&self) -> Ratio<T>

Method ceil

fn ceil(&self) -> Ratio<T>

Method round

fn round(&self) -> Ratio<T>

Method trunc

fn trunc(&self) -> Ratio<T>

Method fract

fn fract(&self) -> Ratio<T>

Implementation of Fractional for Ratio<T> where <T: Clone + Integer + Ord>

Method recip

fn recip(&self) -> Ratio<T>

Implementation of ToStr for Ratio<T> where <T: ToStr>

Method to_str

fn to_str(&self) -> ~str

Renders as numer/denom.

Implementation of ToStrRadix for Ratio<T> where <T: ToStrRadix>

Method to_str_radix

fn to_str_radix(&self, radix: uint) -> ~str

Renders as numer/denom where the numbers are in base radix.

Implementation of FromStr for Ratio<T> where <T: FromStr + Clone + Integer + Ord>

Method from_str

fn from_str(s: &str) -> Option<Ratio<T>>

Parses numer/denom.

Implementation of FromStrRadix for Ratio<T> where <T: FromStrRadix + Clone + Integer + Ord>

Method from_str_radix

fn from_str_radix(s: &str, radix: uint) -> Option<Ratio<T>>

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