[−][src]Struct sp_runtime::Rational128
Re-export top-level arithmetic stuff. A wrapper for any rational number with a 128 bit numerator and denominator.
Implementations
impl Rational128[src][−]
Re-export top-level arithmetic stuff.
pub fn zero() -> Rational128[src][−]
Nothing.
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][−]
self,
other: Rational128
) -> Result<Rational128, &'static str>
Addition. Simply tries to unify the denominators and add the numerators.
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][−]
self,
other: Rational128
) -> Result<Rational128, &'static str>
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.
Trait Implementations
impl Clone for Rational128[src][+]
impl Copy for Rational128[src]
impl Debug for Rational128[src][+]
impl Default for Rational128[src][+]
impl Eq for Rational128[src]
impl Ord for Rational128[src][+]
impl PartialEq<Rational128> for Rational128[src][+]
impl PartialOrd<Rational128> for Rational128[src][+]
Auto Trait Implementations
impl RefUnwindSafe for Rational128
impl Send for Rational128
impl Sync for Rational128
impl Unpin for Rational128
impl UnwindSafe for Rational128
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src][+]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src][+]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src][+]
T: ?Sized,
impl<T> CheckedConversion for T[src][+]
impl<T> Clear for T where
T: PartialEq<T> + Eq + Default, [src][+]
T: PartialEq<T> + Eq + Default,
impl<T> Clear for T where
T: InitializableFromZeroed + ?Sized, [src][+]
T: InitializableFromZeroed + ?Sized,
impl<T> From<T> for T[src][+]
impl<T> InitializableFromZeroed for T where
T: Default, [src][+]
T: Default,
impl<T, U> Into<U> for T where
U: From<T>, [src][+]
U: From<T>,
impl<T, Outer> IsWrappedBy<Outer> for T where
Outer: AsRef<T> + AsMut<T> + From<T>,
T: From<Outer>, [src][+]
Outer: AsRef<T> + AsMut<T> + From<T>,
T: From<Outer>,
impl<T> MaybeDebug for T where
T: Debug, [src]
T: Debug,
impl<T> MaybeDebug for T where
T: Debug, [src]
T: Debug,
impl<T> MaybeRefUnwindSafe for T where
T: RefUnwindSafe, [src]
T: RefUnwindSafe,
impl<T> Member for T where
T: 'static + Clone + PartialEq<T> + Eq + Send + Sync + Debug, [src]
T: 'static + Clone + PartialEq<T> + Eq + Send + Sync + Debug,
impl<T> Same<T> for T[src]
type Output = T
Should always be Self
impl<T> SaturatedConversion for T[src][+]
impl<T> ToOwned for T where
T: Clone, [src][+]
T: Clone,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src][+]
U: Into<T>,
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src][+]
U: TryFrom<T>,
impl<S, T> UncheckedInto<T> for S where
T: UncheckedFrom<S>, [src][+]
T: UncheckedFrom<S>,
impl<T, S> UniqueSaturatedInto<T> for S where
S: TryInto<T>,
T: Bounded, [src][+]
S: TryInto<T>,
T: Bounded,
impl<V, T> VZip<V> for T where
V: MultiLane<T>, [src][+]
V: MultiLane<T>,