Struct sp_arithmetic::rational::Rational128
source · [−]pub struct Rational128(_, _);
Expand description
A wrapper for any rational number with a 128 bit numerator and denominator.
Implementations
Build from a raw n/d
. This could lead to / 0 if not properly handled.
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.
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.
A saturating add that assumes self
and other
have the same denominator.
A saturating subtraction that assumes self
and other
have the same denominator.
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.
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
Returns the “default value” for a type. Read more
Performs the conversion.
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
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
Mutably borrows from an owned value. Read more
Convert from a value of T
into an equivalent instance of Self
.
Consume self to return an equivalent value of T
.