rational
Types
Functions
pub fn absolute_value(a: Rational) -> Rational
pub fn compare(a: Rational, b: Rational) -> Order
Compares two rational numbers, returning an Order
type that describes their relationship
pub fn from_float(from f: Float, to_nearest inc: Rational) -> Rational
Creates a new rational number from a float, rounding it to the nearest rational increment.
pub fn new(num: Int, den: Int) -> Result(Rational, Nil)
Creates a new rational number from a numerator (top of the fraction) and denominator (bottom).
pub fn new_improper(whole: Int, num: Int, den: Int) -> Result(
Rational,
Nil,
)
Creates a new rational number from an improper fraction, which has a whole number part as well as a numerator and denominator.
pub fn reciprocal(a: Rational) -> Rational
pub fn to_float(r: Rational) -> Float
Returns the neaerest float to the rational number.
pub fn to_mixed_fraction(r: Rational) -> #(Int, Rational)
Takes a rational number and returns it as a tuple representing a mixed fraction, with a whole part and a fractional part.