Struct extra::rational::Ratio

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

Represents the ratio between 2 numbers.

Methods

impl<T: std::clone::Clone + std::num::Integer + std::cmp::Ord> Ratio<T>

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

Create a ratio representing the integer t.

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

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

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

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

Trait Implementations

impl<T: std::clone::Clone> std::clone::Clone for Ratio<T>

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

impl<T: std::ops::Mul + std::cmp::Eq> std::cmp::Eq for Ratio<T>

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

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

impl<T: std::ops::Mul + std::cmp::TotalEq> std::cmp::TotalEq for Ratio<T>

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

impl<T: std::ops::Mul + std::cmp::Ord> std::cmp::Ord for Ratio<T>

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

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

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

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

impl<T: std::ops::Mul + std::cmp::TotalOrd> std::cmp::TotalOrd for Ratio<T>

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

impl<T: std::clone::Clone + std::num::Integer + std::cmp::Ord> std::num::Orderable for Ratio<T>

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

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

fn clamp(&self, mn: &Ratio<T>, mx: &Ratio<T>) -> Ratio<T>

impl<T: std::clone::Clone + std::num::Integer + std::cmp::Ord> std::ops::Mul for Ratio<T>

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

impl<T: std::clone::Clone + std::num::Integer + std::cmp::Ord> std::ops::Div for Ratio<T>

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

impl<T: std::clone::Clone + std::num::Integer + std::cmp::Ord> std::ops::Add for Ratio<T>

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

impl<T: std::clone::Clone + std::num::Integer + std::cmp::Ord> std::ops::Sub for Ratio<T>

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

impl<T: std::clone::Clone + std::num::Integer + std::cmp::Ord> std::ops::Rem for Ratio<T>

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

impl<T: std::clone::Clone + std::num::Integer + std::cmp::Ord> std::ops::Neg for Ratio<T>

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

impl<T: std::clone::Clone + std::num::Integer + std::cmp::Ord> std::num::Zero for Ratio<T>

fn zero() -> Ratio<T>

fn is_zero(&self) -> bool

impl<T: std::clone::Clone + std::num::Integer + std::cmp::Ord> std::num::One for Ratio<T>

fn one() -> Ratio<T>

impl<T: std::clone::Clone + std::num::Integer + std::cmp::Ord> std::num::Num for Ratio<T>

impl<T: std::clone::Clone + std::num::Integer + std::cmp::Ord> std::num::Round for Ratio<T>

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

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

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

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

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

impl<T: std::clone::Clone + std::num::Integer + std::cmp::Ord> std::num::Fractional for Ratio<T>

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

impl<T: std::to_str::ToStr> std::to_str::ToStr for Ratio<T>

fn to_str(&self) -> ~str

Renders as numer/denom.

impl<T: std::num::ToStrRadix> std::num::ToStrRadix for Ratio<T>

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

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

impl<T: std::from_str::FromStr + std::clone::Clone + std::num::Integer + std::cmp::Ord> std::from_str::FromStr for Ratio<T>

fn from_str(s: &str) -> std::option::Option

Parses numer/denom.

impl<T: std::num::FromStrRadix + std::clone::Clone + std::num::Integer + std::cmp::Ord> std::num::FromStrRadix for Ratio<T>

fn from_str_radix(s: &str, radix: uint) -> std::option::Option

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