Struct ramp::rational::Rational
[−]
[src]
pub struct Rational { // some fields omitted }
An arbitrary-precision rational number.
This type is used to represent numbers in the form a / b
where a
and b
are integers and b
is non-zero.
Methods
impl Rational
[src]
fn abs(self) -> Rational
Returns the absolute value of this Rational
fn new(n: Int, d: Int) -> Rational
fn normalized(&self) -> bool
Returns whether or not this rational is normalized or not
fn normalize(&mut self)
Normalize this Rational.
This method will cause the value to be represented in the
form a/b
where a
and b
are relatively prime. It also
ensures that the denominator is positive.
Normalizing rationals will result in faster calculations as it ensures that the numerator and denominator are as small as they can be.
fn invert(self) -> Rational
Returns the reciprocal of this Rational
fn round(self) -> Int
Returns this Rational to the nearest Int
fn sign(&self) -> i32
Returns the sign of the Int as either -1, 0 or 1 for self being negative, zero or positive, respectively.
fn to_f64(&self) -> f64
Converts this Rational to an f64
value.
Trait Implementations
impl Clone for Rational
[src]
fn clone(&self) -> Rational
Returns a copy of the value. Read more
fn clone_from(&mut self, other: &Rational)
Performs copy-assignment from source
. Read more
impl Default for Rational
[src]
impl PartialEq<Rational> for Rational
[src]
fn eq(&self, other: &Rational) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0
This method tests for !=
.
impl PartialEq<Int> for Rational
[src]
fn eq(&self, other: &Int) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0
This method tests for !=
.
impl Eq for Rational
[src]
impl Ord for Rational
[src]
fn cmp(&self, other: &Rational) -> Ordering
This method returns an Ordering
between self
and other
. Read more
impl PartialOrd<Rational> for Rational
[src]
fn partial_cmp(&self, other: &Rational) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Rhs) -> bool
1.0.0
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Rhs) -> bool
1.0.0
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &Rhs) -> bool
1.0.0
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Rhs) -> bool
1.0.0
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl PartialOrd<Int> for Rational
[src]
fn partial_cmp(&self, other: &Int) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Rhs) -> bool
1.0.0
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Rhs) -> bool
1.0.0
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &Rhs) -> bool
1.0.0
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Rhs) -> bool
1.0.0
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl Hash for Rational
[src]
fn hash<H>(&self, state: &mut H) where H: Hasher
Feeds this value into the state given, updating the hasher as necessary.
fn hash_slice<H>(data: &[Self], state: &mut H) where H: Hasher
1.3.0
Feeds a slice of this type into the state provided.
impl AddAssign<Rational> for Rational
[src]
fn add_assign(&mut self, other: Rational)
The method for the +=
operator
impl<'a> AddAssign<&'a Rational> for Rational
[src]
fn add_assign(&mut self, other: &'a Rational)
The method for the +=
operator
impl AddAssign<Int> for Rational
[src]
fn add_assign(&mut self, other: Int)
The method for the +=
operator
impl<'a> AddAssign<&'a Int> for Rational
[src]
fn add_assign(&mut self, other: &'a Int)
The method for the +=
operator
impl Add<Rational> for Rational
[src]
type Output = Rational
The resulting type after applying the +
operator
fn add(self, other: Rational) -> Rational
The method for the +
operator
impl<'a> Add<&'a Rational> for Rational
[src]
type Output = Rational
The resulting type after applying the +
operator
fn add(self, other: &'a Rational) -> Rational
The method for the +
operator
impl<'a> Add<Rational> for &'a Rational
[src]
type Output = Rational
The resulting type after applying the +
operator
fn add(self, other: Rational) -> Rational
The method for the +
operator
impl<'a> Add<&'a Rational> for &'a Rational
[src]
type Output = Rational
The resulting type after applying the +
operator
fn add(self, other: &'a Rational) -> Rational
The method for the +
operator
impl Add<Int> for Rational
[src]
type Output = Rational
The resulting type after applying the +
operator
fn add(self, other: Int) -> Rational
The method for the +
operator
impl<'a> Add<&'a Int> for Rational
[src]
type Output = Rational
The resulting type after applying the +
operator
fn add(self, other: &'a Int) -> Rational
The method for the +
operator
impl<'a> Add<Int> for &'a Rational
[src]
type Output = Rational
The resulting type after applying the +
operator
fn add(self, other: Int) -> Rational
The method for the +
operator
impl<'a> Add<&'a Int> for &'a Rational
[src]
type Output = Rational
The resulting type after applying the +
operator
fn add(self, other: &'a Int) -> Rational
The method for the +
operator
impl SubAssign<Rational> for Rational
[src]
fn sub_assign(&mut self, other: Rational)
The method for the -=
operator
impl<'a> SubAssign<&'a Rational> for Rational
[src]
fn sub_assign(&mut self, other: &'a Rational)
The method for the -=
operator
impl Sub<Rational> for Rational
[src]
type Output = Rational
The resulting type after applying the -
operator
fn sub(self, other: Rational) -> Rational
The method for the -
operator
impl<'a> Sub<&'a Rational> for Rational
[src]
type Output = Rational
The resulting type after applying the -
operator
fn sub(self, other: &'a Rational) -> Rational
The method for the -
operator
impl<'a> Sub<Rational> for &'a Rational
[src]
type Output = Rational
The resulting type after applying the -
operator
fn sub(self, other: Rational) -> Rational
The method for the -
operator
impl<'a> Sub<&'a Rational> for &'a Rational
[src]
type Output = Rational
The resulting type after applying the -
operator
fn sub(self, other: &'a Rational) -> Rational
The method for the -
operator
impl<'a> MulAssign<&'a Rational> for Rational
[src]
fn mul_assign(&mut self, other: &'a Rational)
The method for the *=
operator
impl MulAssign<Rational> for Rational
[src]
fn mul_assign(&mut self, other: Rational)
The method for the *=
operator
impl MulAssign<Int> for Rational
[src]
fn mul_assign(&mut self, other: Int)
The method for the *=
operator
impl<'a> MulAssign<&'a Int> for Rational
[src]
fn mul_assign(&mut self, other: &'a Int)
The method for the *=
operator
impl Mul<Rational> for Rational
[src]
type Output = Rational
The resulting type after applying the *
operator
fn mul(self, other: Rational) -> Rational
The method for the *
operator
impl<'a> Mul<&'a Rational> for Rational
[src]
type Output = Rational
The resulting type after applying the *
operator
fn mul(self, other: &'a Rational) -> Rational
The method for the *
operator
impl<'a> Mul<Rational> for &'a Rational
[src]
type Output = Rational
The resulting type after applying the *
operator
fn mul(self, other: Rational) -> Rational
The method for the *
operator
impl<'a> Mul<&'a Rational> for &'a Rational
[src]
type Output = Rational
The resulting type after applying the *
operator
fn mul(self, other: &'a Rational) -> Rational
The method for the *
operator
impl Mul<Int> for Rational
[src]
type Output = Rational
The resulting type after applying the *
operator
fn mul(self, other: Int) -> Rational
The method for the *
operator
impl<'a> Mul<&'a Int> for Rational
[src]
type Output = Rational
The resulting type after applying the *
operator
fn mul(self, other: &'a Int) -> Rational
The method for the *
operator
impl<'a> Mul<Int> for &'a Rational
[src]
type Output = Rational
The resulting type after applying the *
operator
fn mul(self, other: Int) -> Rational
The method for the *
operator
impl<'a> Mul<&'a Int> for &'a Rational
[src]
type Output = Rational
The resulting type after applying the *
operator
fn mul(self, other: &'a Int) -> Rational
The method for the *
operator
impl DivAssign<Rational> for Rational
[src]
fn div_assign(&mut self, other: Rational)
The method for the /=
operator
impl<'a> DivAssign<&'a Rational> for Rational
[src]
fn div_assign(&mut self, other: &'a Rational)
The method for the /=
operator
impl DivAssign<Int> for Rational
[src]
fn div_assign(&mut self, other: Int)
The method for the /=
operator
impl<'a> DivAssign<&'a Int> for Rational
[src]
fn div_assign(&mut self, other: &'a Int)
The method for the /=
operator
impl Div<Rational> for Rational
[src]
type Output = Rational
The resulting type after applying the /
operator
fn div(self, other: Rational) -> Rational
The method for the /
operator
impl<'a> Div<&'a Rational> for Rational
[src]
type Output = Rational
The resulting type after applying the /
operator
fn div(self, other: &'a Rational) -> Rational
The method for the /
operator
impl<'a> Div<Rational> for &'a Rational
[src]
type Output = Rational
The resulting type after applying the /
operator
fn div(self, other: Rational) -> Rational
The method for the /
operator
impl<'a> Div<&'a Rational> for &'a Rational
[src]
type Output = Rational
The resulting type after applying the /
operator
fn div(self, other: &'a Rational) -> Rational
The method for the /
operator
impl Div<Int> for Rational
[src]
type Output = Rational
The resulting type after applying the /
operator
fn div(self, other: Int) -> Rational
The method for the /
operator
impl<'a> Div<&'a Int> for Rational
[src]
type Output = Rational
The resulting type after applying the /
operator
fn div(self, other: &'a Int) -> Rational
The method for the /
operator
impl<'a> Div<Int> for &'a Rational
[src]
type Output = Rational
The resulting type after applying the /
operator
fn div(self, other: Int) -> Rational
The method for the /
operator
impl<'a> Div<&'a Int> for &'a Rational
[src]
type Output = Rational
The resulting type after applying the /
operator
fn div(self, other: &'a Int) -> Rational
The method for the /
operator