# [−][src]Struct sp_runtime::Rational128

`pub struct Rational128(_, _);`

Re-export top-level arithmetic stuff. A wrapper for any rational number with a 128 bit numerator and denominator.

## Implementations

### `impl Rational128`[src]

Zero.

One

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

If it is zero or not

#### `pub fn from(n: u128, d: u128) -> Rational128`[src]

Build from a raw `n/d`.

#### `pub fn from_unchecked(n: u128, d: u128) -> Rational128`[src]

Build from a raw `n/d`. This could lead to / 0 if not properly handled.

#### `pub fn n(&self) -> u128`[src]

Return the numerator.

#### `pub fn d(&self) -> u128`[src]

Return the denominator.

#### `pub fn to_den(self, den: u128) -> Result<Rational128, &'static str>`[src]

Convert `self` to a similar rational number where denominator is the given `den`. This only returns if the result is accurate. `Err` is returned if the result cannot be accurately calculated.

#### `pub fn lcm(&self, other: &Rational128) -> Result<u128, &'static str>`[src]

Get the least common divisor of `self` and `other`.

This only returns if the result is accurate. `Err` is returned if the result cannot be accurately calculated.

#### `pub fn lazy_saturating_add(self, other: Rational128) -> Rational128`[src]

A saturating add that assumes `self` and `other` have the same denominator.

#### `pub fn lazy_saturating_sub(self, other: Rational128) -> Rational128`[src]

A saturating subtraction that assumes `self` and `other` have the same denominator.

#### `pub fn checked_add(    self,     other: Rational128) -> Result<Rational128, &'static str>`[src]

Overflow might happen during any of the steps. Error is returned in such cases.

#### `pub fn checked_sub(    self,     other: Rational128) -> Result<Rational128, &'static str>`[src]

Subtraction. Simply tries to unify the denominators and subtract the numerators.

Overflow might happen during any of the steps. None is returned in such cases.

## Blanket Implementations

### `impl<T, Outer> IsWrappedBy<Outer> for T where    Outer: AsRef<T> + AsMut<T> + From<T>,    T: From<Outer>, `[src]

#### `pub fn from_ref(outer: &Outer) -> &T`[src]

Get a reference to the inner from the outer.

#### `pub fn from_mut(outer: &mut Outer) -> &mut T`[src]

Get a mutable reference to the inner from the outer.

### `impl<T> Same<T> for T`

#### `type Output = T`

Should always be `Self`

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

#### `type Owned = T`

The resulting type after obtaining ownership.

### `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.