Rational numbers
BigRational
- Alias for arbitrary precision rationals.Rational
- Alias for a Ratio
of machine-sized integers.Rational32
Rational64
Ratio
- Represents the ratio between 2 numbers.of ::std::clone::Clone for Ratio<T> where <T: ::std::clone::Clone>
- Automatically derived.for Ratio<T> where <T: Clone + Integer + Ord>
of Eq for Ratio<T> where <T: Mul<T, T> + Eq>
of TotalEq for Ratio<T> where <T: Mul<T, T> + TotalEq>
of Ord for Ratio<T> where <T: Mul<T, T> + Ord>
of TotalOrd for Ratio<T> where <T: Mul<T, T> + TotalOrd>
of Mul<Ratio<T>, Ratio<T>> for Ratio<T> where <T: Clone + Integer + Ord>
of Div<Ratio<T>, Ratio<T>> for Ratio<T> where <T: Clone + Integer + Ord>
of Add<Ratio<T>, Ratio<T>> for Ratio<T> where <T: Clone + Integer + Ord>
of Sub<Ratio<T>, Ratio<T>> for Ratio<T> where <T: Clone + Integer + Ord>
of Rem<Ratio<T>, Ratio<T>> for Ratio<T> where <T: Clone + Integer + Ord>
of Neg<Ratio<T>> for Ratio<T> where <T: Clone + Integer + Ord>
of Zero for Ratio<T> where <T: Clone + Integer + Ord>
of One for Ratio<T> where <T: Clone + Integer + Ord>
of Num for Ratio<T> where <T: Clone + Integer + Ord>
of Round for Ratio<T> where <T: Clone + Integer + Ord>
of Fractional for Ratio<T> where <T: Clone + Integer + Ord>
of ToStr for Ratio<T> where <T: ToStr>
of ToStrRadix for Ratio<T> where <T: ToStrRadix>
of FromStr for Ratio<T> where <T: FromStr + Clone + Integer + Ord>
of FromStrRadix for Ratio<T> where <T: FromStrRadix + Clone + Integer + Ord>
BigRational
type BigRational = Ratio<BigInt>
Alias for arbitrary precision rationals.
Rational
type Rational = Ratio<int>
Alias for a Ratio
of machine-sized integers.
Rational32
type Rational32 = Ratio<i32>
Rational64
type Rational64 = Ratio<i64>
Ratio
pub struct Ratio<T> {
numer: T,
denom: T,
}
Represents the ratio between 2 numbers.
::std::clone::Clone
for Ratio<T>
where <T: ::std::clone::Clone>
Automatically derived.
clone
fn clone(&self) -> Ratio<T>
Ratio<T>
where <T: Clone + Integer + Ord>
from_integer
fn from_integer(t: T) -> Ratio<T>
Create a ratio representing the integer t
.
new_raw
fn new_raw(numer: T, denom: T) -> Ratio<T>
Create a ratio without checking for denom == 0
or reducing.
new
fn new(numer: T, denom: T) -> Ratio<T>
Create a new Ratio. Fails if denom == 0
.
Eq
for Ratio<T>
where <T: Mul<T, T> + Eq>
eq
fn eq(&self, other: &Ratio<T>) -> bool
ne
fn ne(&self, other: &Ratio<T>) -> bool
TotalEq
for Ratio<T>
where <T: Mul<T, T> + TotalEq>
equals
fn equals(&self, other: &Ratio<T>) -> bool
Ord
for Ratio<T>
where <T: Mul<T, T> + Ord>
lt
fn lt(&self, other: &Ratio<T>) -> bool
gt
fn gt(&self, other: &Ratio<T>) -> bool
le
fn le(&self, other: &Ratio<T>) -> bool
ge
fn ge(&self, other: &Ratio<T>) -> bool
TotalOrd
for Ratio<T>
where <T: Mul<T, T> + TotalOrd>
cmp
fn cmp(&self, other: &Ratio<T>) -> cmp::Ordering
Mul<Ratio<T>, Ratio<T>>
for Ratio<T>
where <T: Clone + Integer + Ord>
mul
fn mul(&self, rhs: &Ratio<T>) -> Ratio<T>
Div<Ratio<T>, Ratio<T>>
for Ratio<T>
where <T: Clone + Integer + Ord>
div
fn div(&self, rhs: &Ratio<T>) -> Ratio<T>
Add<Ratio<T>, Ratio<T>>
for Ratio<T>
where <T: Clone + Integer + Ord>
add
fn add(&self, rhs: &Ratio<T>) -> Ratio<T>
Sub<Ratio<T>, Ratio<T>>
for Ratio<T>
where <T: Clone + Integer + Ord>
sub
fn sub(&self, rhs: &Ratio<T>) -> Ratio<T>
Rem<Ratio<T>, Ratio<T>>
for Ratio<T>
where <T: Clone + Integer + Ord>
rem
fn rem(&self, rhs: &Ratio<T>) -> Ratio<T>
Neg<Ratio<T>>
for Ratio<T>
where <T: Clone + Integer + Ord>
neg
fn neg(&self) -> Ratio<T>
Zero
for Ratio<T>
where <T: Clone + Integer + Ord>
zero
fn zero() -> Ratio<T>
is_zero
fn is_zero(&self) -> bool
One
for Ratio<T>
where <T: Clone + Integer + Ord>
one
fn one() -> Ratio<T>
Num
for Ratio<T>
where <T: Clone + Integer + Ord>
Round
for Ratio<T>
where <T: Clone + Integer + Ord>
floor
fn floor(&self) -> Ratio<T>
ceil
fn ceil(&self) -> Ratio<T>
round
fn round(&self) -> Ratio<T>
trunc
fn trunc(&self) -> Ratio<T>
fract
fn fract(&self) -> Ratio<T>
Fractional
for Ratio<T>
where <T: Clone + Integer + Ord>
recip
fn recip(&self) -> Ratio<T>
ToStr
for Ratio<T>
where <T: ToStr>
to_str
fn to_str(&self) -> ~str
Renders as numer/denom
.
ToStrRadix
for Ratio<T>
where <T: ToStrRadix>
to_str_radix
fn to_str_radix(&self, radix: uint) -> ~str
Renders as numer/denom
where the numbers are in base radix
.
FromStr
for Ratio<T>
where <T: FromStr + Clone + Integer + Ord>
from_str
fn from_str(s: &str) -> Option<Ratio<T>>
Parses numer/denom
.
FromStrRadix
for Ratio<T>
where <T: FromStrRadix + Clone + Integer + Ord>
from_str_radix
fn from_str_radix(s: &str, radix: uint) -> Option<Ratio<T>>
Parses numer/denom
where the numbers are in base radix
.