Type Alias num_rational::Rational32
source · pub type Rational32 = Ratio<i32>;
Expand description
Alias for a Ratio
of 32-bit-sized integers.
Aliased Type§
struct Rational32 { /* private fields */ }
Implementations
source§impl<T: Clone + Integer> Ratio<T>
impl<T: Clone + Integer> Ratio<T>
sourcepub fn from_integer(t: T) -> Ratio<T>
pub fn from_integer(t: T) -> Ratio<T>
Creates a Ratio
representing the integer t
.
sourcepub fn to_integer(&self) -> T
pub fn to_integer(&self) -> T
Converts to an integer, rounding towards zero.
sourcepub fn is_integer(&self) -> bool
pub fn is_integer(&self) -> bool
Returns true if the rational number is an integer (denominator is 1).
sourcepub fn reduced(&self) -> Ratio<T>
pub fn reduced(&self) -> Ratio<T>
Returns a reduced copy of self.
In general, it is not necessary to use this method, as the only
method of procuring a non-reduced fraction is through new_raw
.
Trait Implementations
source§impl<'a, T: Clone + Integer + NumAssign> SubAssign<&'a Ratio<T>> for Ratio<T>
impl<'a, T: Clone + Integer + NumAssign> SubAssign<&'a Ratio<T>> for Ratio<T>
source§fn sub_assign(&mut self, other: &Ratio<T>)
fn sub_assign(&mut self, other: &Ratio<T>)
Performs the
-=
operation. Read moresource§impl<T: Clone + Integer + NumAssign> MulAssign<T> for Ratio<T>
impl<T: Clone + Integer + NumAssign> MulAssign<T> for Ratio<T>
source§fn mul_assign(&mut self, other: T)
fn mul_assign(&mut self, other: T)
Performs the
*=
operation. Read moresource§impl<T: Clone + Integer + NumAssign> RemAssign for Ratio<T>
impl<T: Clone + Integer + NumAssign> RemAssign for Ratio<T>
source§fn rem_assign(&mut self, other: Ratio<T>)
fn rem_assign(&mut self, other: Ratio<T>)
Performs the
%=
operation. Read moresource§impl<'a, T: Clone + Integer + NumAssign> AddAssign<&'a Ratio<T>> for Ratio<T>
impl<'a, T: Clone + Integer + NumAssign> AddAssign<&'a Ratio<T>> for Ratio<T>
source§fn add_assign(&mut self, other: &Ratio<T>)
fn add_assign(&mut self, other: &Ratio<T>)
Performs the
+=
operation. Read moresource§impl<'a, T: Clone + Integer + NumAssign> MulAssign<&'a Ratio<T>> for Ratio<T>
impl<'a, T: Clone + Integer + NumAssign> MulAssign<&'a Ratio<T>> for Ratio<T>
source§fn mul_assign(&mut self, other: &Ratio<T>)
fn mul_assign(&mut self, other: &Ratio<T>)
Performs the
*=
operation. Read moresource§impl<'a, T: Clone + Integer + NumAssign> DivAssign<&'a T> for Ratio<T>
impl<'a, T: Clone + Integer + NumAssign> DivAssign<&'a T> for Ratio<T>
source§fn div_assign(&mut self, other: &T)
fn div_assign(&mut self, other: &T)
Performs the
/=
operation. Read moresource§impl<'a, T: Clone + Integer + NumAssign> AddAssign<&'a T> for Ratio<T>
impl<'a, T: Clone + Integer + NumAssign> AddAssign<&'a T> for Ratio<T>
source§fn add_assign(&mut self, other: &T)
fn add_assign(&mut self, other: &T)
Performs the
+=
operation. Read moreimpl<T: Copy> Copy for Ratio<T>
source§impl<T: Clone + Integer + NumAssign> AddAssign for Ratio<T>
impl<T: Clone + Integer + NumAssign> AddAssign for Ratio<T>
source§fn add_assign(&mut self, other: Ratio<T>)
fn add_assign(&mut self, other: Ratio<T>)
Performs the
+=
operation. Read moresource§impl<'a, T: Clone + Integer + NumAssign> RemAssign<&'a Ratio<T>> for Ratio<T>
impl<'a, T: Clone + Integer + NumAssign> RemAssign<&'a Ratio<T>> for Ratio<T>
source§fn rem_assign(&mut self, other: &Ratio<T>)
fn rem_assign(&mut self, other: &Ratio<T>)
Performs the
%=
operation. Read moresource§impl<'a, T: Clone + Integer + NumAssign> SubAssign<&'a T> for Ratio<T>
impl<'a, T: Clone + Integer + NumAssign> SubAssign<&'a T> for Ratio<T>
source§fn sub_assign(&mut self, other: &T)
fn sub_assign(&mut self, other: &T)
Performs the
-=
operation. Read moresource§impl<T: Clone + Integer + CheckedMul + CheckedSub> CheckedSub for Ratio<T>
impl<T: Clone + Integer + CheckedMul + CheckedSub> CheckedSub for Ratio<T>
source§impl<T: Clone + Integer + CheckedMul + CheckedAdd> CheckedAdd for Ratio<T>
impl<T: Clone + Integer + CheckedMul + CheckedAdd> CheckedAdd for Ratio<T>
source§impl<T: Clone + Integer + NumAssign> RemAssign<T> for Ratio<T>
impl<T: Clone + Integer + NumAssign> RemAssign<T> for Ratio<T>
source§fn rem_assign(&mut self, other: T)
fn rem_assign(&mut self, other: T)
Performs the
%=
operation. Read moresource§impl<T: Clone + Integer + NumAssign> AddAssign<T> for Ratio<T>
impl<T: Clone + Integer + NumAssign> AddAssign<T> for Ratio<T>
source§fn add_assign(&mut self, other: T)
fn add_assign(&mut self, other: T)
Performs the
+=
operation. Read moresource§impl<'a, T: Clone + Integer + NumAssign> RemAssign<&'a T> for Ratio<T>
impl<'a, T: Clone + Integer + NumAssign> RemAssign<&'a T> for Ratio<T>
source§fn rem_assign(&mut self, other: &T)
fn rem_assign(&mut self, other: &T)
Performs the
%=
operation. Read moresource§impl<T> CheckedMul for Ratio<T>
impl<T> CheckedMul for Ratio<T>
source§impl<T: Clone + Integer + NumAssign> DivAssign<T> for Ratio<T>
impl<T: Clone + Integer + NumAssign> DivAssign<T> for Ratio<T>
source§fn div_assign(&mut self, other: T)
fn div_assign(&mut self, other: T)
Performs the
/=
operation. Read moresource§impl<T: FromStr + Clone + Integer> FromStr for Ratio<T>
impl<T: FromStr + Clone + Integer> FromStr for Ratio<T>
§type Err = ParseRatioError
type Err = ParseRatioError
The associated error which can be returned from parsing.
source§impl<T: Clone + Integer> PartialOrd for Ratio<T>
impl<T: Clone + Integer> PartialOrd for Ratio<T>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§impl<'a, T: Clone + Integer + NumAssign> DivAssign<&'a Ratio<T>> for Ratio<T>
impl<'a, T: Clone + Integer + NumAssign> DivAssign<&'a Ratio<T>> for Ratio<T>
source§fn div_assign(&mut self, other: &Ratio<T>)
fn div_assign(&mut self, other: &Ratio<T>)
Performs the
/=
operation. Read moresource§impl<'a, T: Clone + Integer + NumAssign> MulAssign<&'a T> for Ratio<T>
impl<'a, T: Clone + Integer + NumAssign> MulAssign<&'a T> for Ratio<T>
source§fn mul_assign(&mut self, other: &T)
fn mul_assign(&mut self, other: &T)
Performs the
*=
operation. Read moresource§impl<T: Clone + Integer + Signed> Signed for Ratio<T>
impl<T: Clone + Integer + Signed> Signed for Ratio<T>
source§fn abs_sub(&self, other: &Ratio<T>) -> Ratio<T>
fn abs_sub(&self, other: &Ratio<T>) -> Ratio<T>
The positive difference of two numbers. Read more
source§fn is_positive(&self) -> bool
fn is_positive(&self) -> bool
Returns true if the number is positive and false if the number is zero or negative.
source§fn is_negative(&self) -> bool
fn is_negative(&self) -> bool
Returns true if the number is negative and false if the number is zero or positive.
source§impl<T: Clone + Integer + NumAssign> DivAssign for Ratio<T>
impl<T: Clone + Integer + NumAssign> DivAssign for Ratio<T>
source§fn div_assign(&mut self, other: Ratio<T>)
fn div_assign(&mut self, other: Ratio<T>)
Performs the
/=
operation. Read moresource§impl<T: Clone + Integer> Num for Ratio<T>
impl<T: Clone + Integer> Num for Ratio<T>
source§fn from_str_radix(s: &str, radix: u32) -> Result<Ratio<T>, ParseRatioError>
fn from_str_radix(s: &str, radix: u32) -> Result<Ratio<T>, ParseRatioError>
Parses numer/denom
where the numbers are in base radix
.
type FromStrRadixErr = ParseRatioError
source§impl<T: Clone + Integer> Ord for Ratio<T>
impl<T: Clone + Integer> Ord for Ratio<T>
source§impl<T: Clone + Integer + NumAssign> SubAssign<T> for Ratio<T>
impl<T: Clone + Integer + NumAssign> SubAssign<T> for Ratio<T>
source§fn sub_assign(&mut self, other: T)
fn sub_assign(&mut self, other: T)
Performs the
-=
operation. Read moresource§impl<T: Clone + Integer + NumAssign> SubAssign for Ratio<T>
impl<T: Clone + Integer + NumAssign> SubAssign for Ratio<T>
source§fn sub_assign(&mut self, other: Ratio<T>)
fn sub_assign(&mut self, other: Ratio<T>)
Performs the
-=
operation. Read moresource§impl<T: Clone + Integer> PartialEq for Ratio<T>
impl<T: Clone + Integer> PartialEq for Ratio<T>
source§impl<T> CheckedDiv for Ratio<T>
impl<T> CheckedDiv for Ratio<T>
impl<T: Clone + Integer> Eq for Ratio<T>
source§impl<T: Clone + Integer + NumAssign> MulAssign for Ratio<T>
impl<T: Clone + Integer + NumAssign> MulAssign for Ratio<T>
source§fn mul_assign(&mut self, other: Ratio<T>)
fn mul_assign(&mut self, other: Ratio<T>)
Performs the
*=
operation. Read moresource§impl FromPrimitive for Ratio<i32>
impl FromPrimitive for Ratio<i32>
source§fn from_i64(n: i64) -> Option<Self>
fn from_i64(n: i64) -> Option<Self>
Converts an
i64
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned.source§fn from_i128(n: i128) -> Option<Self>
fn from_i128(n: i128) -> Option<Self>
Converts an
i128
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned. Read moresource§fn from_u64(n: u64) -> Option<Self>
fn from_u64(n: u64) -> Option<Self>
Converts an
u64
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned.source§fn from_u128(n: u128) -> Option<Self>
fn from_u128(n: u128) -> Option<Self>
Converts an
u128
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned. Read moresource§fn from_f32(n: f32) -> Option<Self>
fn from_f32(n: f32) -> Option<Self>
Converts a
f32
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned.source§fn from_f64(n: f64) -> Option<Self>
fn from_f64(n: f64) -> Option<Self>
Converts a
f64
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned. Read moresource§fn from_isize(n: isize) -> Option<Self>
fn from_isize(n: isize) -> Option<Self>
Converts an
isize
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned.source§fn from_i8(n: i8) -> Option<Self>
fn from_i8(n: i8) -> Option<Self>
Converts an
i8
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned.source§fn from_i16(n: i16) -> Option<Self>
fn from_i16(n: i16) -> Option<Self>
Converts an
i16
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned.source§fn from_i32(n: i32) -> Option<Self>
fn from_i32(n: i32) -> Option<Self>
Converts an
i32
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned.source§fn from_usize(n: usize) -> Option<Self>
fn from_usize(n: usize) -> Option<Self>
Converts a
usize
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned.source§fn from_u8(n: u8) -> Option<Self>
fn from_u8(n: u8) -> Option<Self>
Converts an
u8
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned.