RationalNat

Unbounded positive rational numbers, based on [Natural] numbers for the fraction.

type alias RationalNat =
{ num : Natural
, denom : Natural
}

Unbounded positive rational numbers, based on [Natural] numbers for both sides of the fraction.

zero : RationalNat

0

fromSafeInt : Int -> RationalNat

Convert from a safe JS integer (< 2^53) to [RationalNat], using 1 for the denominator.

This has the same limitations than the [Natural] function with the same name.

add : RationalNat -> RationalNat -> RationalNat

Addition

Remark that the denominator part will grow due to exact computation. Not simplification is performed.

mul : RationalNat -> RationalNat -> RationalNat

Multiplication

Remark that the denominator part will grow due to exact computation. Not simplification is performed.

floor : RationalNat -> Maybe Natural

Return the integer part of that rational number.

Return [Nothing] if the denominator is 0.