[][src]Struct ketos::integer::Ratio

pub struct Ratio(_);

Arbitrary precision signed integer ratio

Methods

impl Ratio[src]

pub fn new(numer: Integer, denom: Integer) -> Ratio[src]

Constructs a Ratio from numerator and denominator.

Panics

Panics if denom is zero.

pub fn from_f32(f: f32) -> Option<Ratio>[src]

Creates a Ratio with the value of the given f32. Returns None if the value cannot be converted.

pub fn from_f64(f: f64) -> Option<Ratio>[src]

Creates a Ratio with the value of the given f64. Returns None if the value cannot be converted.

pub fn from_integer(i: Integer) -> Ratio[src]

Creates a Ratio from an Integer value.

pub fn to_f32(&self) -> Option<f32>[src]

Returns the Ratio as an f32 value.

pub fn to_f64(&self) -> Option<f64>[src]

Returns the Ratio as an f64 value.

pub fn to_integer(&self) -> Integer[src]

Truncates a Ratio and returns the whole portion as an Integer.

pub fn is_integer(&self) -> bool[src]

Returns whether the Ratio is an integer; i.e. its denominator is 1.

pub fn abs(&self) -> Ratio[src]

Returns the absolute value of the Ratio.

pub fn ceil(&self) -> Ratio[src]

Returns the Ratio rounded towards positive infinity.

pub fn floor(&self) -> Ratio[src]

Returns the Ratio rounded towards negative infinity.

pub fn fract(&self) -> Ratio[src]

Returns the fractional portion of a Ratio.

pub fn round(&self) -> Ratio[src]

Returns the Ratio rounded to the nearest integer. Rounds half-way cases away from zero.

pub fn trunc(&self) -> Ratio[src]

Returns the Ratio rounded towards zero.

pub fn recip(&self) -> Ratio[src]

Returns the reciprocal of a Ratio.

Panics

Panics if the numerator is zero.

pub fn numer(&self) -> &Integer[src]

Returns the Ratio's numerator.

pub fn denom(&self) -> &Integer[src]

Returns the Ratio's denominator.

pub fn is_zero(&self) -> bool[src]

Returns whether the Ratio is equal to zero.

pub fn is_negative(&self) -> bool[src]

Returns whether the Ratio is less than zero.

pub fn is_positive(&self) -> bool[src]

Returns whether the Ratio is greater than zero.

pub fn zero() -> Ratio[src]

Returns a Ratio of value zero.

pub fn one() -> Ratio[src]

Returns a Ratio of value one.

Trait Implementations

impl<'a> Add<&'a Ratio> for Ratio[src]

type Output = Ratio

The resulting type after applying the + operator.

impl<'a, 'b> Add<&'b Ratio> for &'a Ratio[src]

type Output = Ratio

The resulting type after applying the + operator.

impl Add<Ratio> for Ratio[src]

type Output = Ratio

The resulting type after applying the + operator.

impl<'a> Add<Ratio> for &'a Ratio[src]

type Output = Ratio

The resulting type after applying the + operator.

impl<'a> AddAssign<&'a Ratio> for Ratio[src]

impl AddAssign<Ratio> for Ratio[src]

impl Clone for Ratio[src]

impl Debug for Ratio[src]

impl Display for Ratio[src]

impl<'a> Div<&'a Ratio> for Ratio[src]

type Output = Ratio

The resulting type after applying the / operator.

impl<'a, 'b> Div<&'b Ratio> for &'a Ratio[src]

type Output = Ratio

The resulting type after applying the / operator.

impl Div<Ratio> for Ratio[src]

type Output = Ratio

The resulting type after applying the / operator.

impl<'a> Div<Ratio> for &'a Ratio[src]

type Output = Ratio

The resulting type after applying the / operator.

impl<'a> DivAssign<&'a Ratio> for Ratio[src]

impl DivAssign<Ratio> for Ratio[src]

impl Eq for Ratio[src]

impl From<Ratio> for Value[src]

impl FromStr for Ratio[src]

type Err = FromStrRatioError

The associated error which can be returned from parsing.

impl FromValue for Ratio[src]

impl<'a> FromValueRef<'a> for &'a Ratio[src]

impl<'a> Mul<&'a Ratio> for Ratio[src]

type Output = Ratio

The resulting type after applying the * operator.

impl<'a, 'b> Mul<&'b Ratio> for &'a Ratio[src]

type Output = Ratio

The resulting type after applying the * operator.

impl Mul<Ratio> for Ratio[src]

type Output = Ratio

The resulting type after applying the * operator.

impl<'a> Mul<Ratio> for &'a Ratio[src]

type Output = Ratio

The resulting type after applying the * operator.

impl<'a> MulAssign<&'a Ratio> for Ratio[src]

impl MulAssign<Ratio> for Ratio[src]

impl Neg for Ratio[src]

type Output = Ratio

The resulting type after applying the - operator.

impl<'a> Neg for &'a Ratio[src]

type Output = Ratio

The resulting type after applying the - operator.

impl Ord for Ratio[src]

impl PartialEq<Integer> for Ratio[src]

impl PartialEq<Ratio> for Ratio[src]

impl PartialEq<Ratio> for Integer[src]

impl PartialOrd<Ratio> for Ratio[src]

impl<'a> Rem<&'a Ratio> for Ratio[src]

type Output = Ratio

The resulting type after applying the % operator.

impl<'a, 'b> Rem<&'b Ratio> for &'a Ratio[src]

type Output = Ratio

The resulting type after applying the % operator.

impl Rem<Ratio> for Ratio[src]

type Output = Ratio

The resulting type after applying the % operator.

impl<'a> Rem<Ratio> for &'a Ratio[src]

type Output = Ratio

The resulting type after applying the % operator.

impl<'a> RemAssign<&'a Ratio> for Ratio[src]

impl RemAssign<Ratio> for Ratio[src]

impl StructuralEq for Ratio[src]

impl StructuralPartialEq for Ratio[src]

impl<'a> Sub<&'a Ratio> for Ratio[src]

type Output = Ratio

The resulting type after applying the - operator.

impl<'a, 'b> Sub<&'b Ratio> for &'a Ratio[src]

type Output = Ratio

The resulting type after applying the - operator.

impl Sub<Ratio> for Ratio[src]

type Output = Ratio

The resulting type after applying the - operator.

impl<'a> Sub<Ratio> for &'a Ratio[src]

type Output = Ratio

The resulting type after applying the - operator.

impl<'a> SubAssign<&'a Ratio> for Ratio[src]

impl SubAssign<Ratio> for Ratio[src]

impl Zero for Ratio[src]

Auto Trait Implementations

impl RefUnwindSafe for Ratio

impl Send for Ratio

impl Sync for Ratio

impl Unpin for Ratio

impl UnwindSafe for Ratio

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, Rhs> NumAssignOps<Rhs> for T where
    T: AddAssign<Rhs> + SubAssign<Rhs> + MulAssign<Rhs> + DivAssign<Rhs> + RemAssign<Rhs>, 
[src]

impl<T, Rhs, Output> NumOps<Rhs, Output> for T where
    T: Sub<Rhs, Output = Output> + Mul<Rhs, Output = Output> + Div<Rhs, Output = Output> + Add<Rhs, Output = Output> + Rem<Rhs, Output = Output>, 
[src]

impl<T, Base> RefNum<Base> for T where
    T: NumOps<Base, Base> + NumOps<&'r Base, Base>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,