Arbitrary-precision rational numbers, represented as a ratio of two Int
values.
ratio : Basics.Int -> Basics.Int -> Rational
Forms the ratio of two integers.
ratioBounded : Basics.Int -> Basics.Int -> Result Numeric.ArithmeticError.ArithmeticError Rational
Forms the ratio of two integers while checking for Overflow
/Underflow
.
fromInt : Basics.Int -> Rational
Converts Int
to Rational
.
toFloat : Rational -> Basics.Float
Converts Rational to Float
toString : Rational -> String
Printing Rational
to String
representation.
inverse : Rational -> Rational
Inverse numerator and denominator of the Rational
.
toPropperFraction : Rational -> ( Basics.Int, Rational )
The function toProperFraction
takes a real fractional number x
and returns a pair ( n, f )
such that x = n + f
, and:
n
is an integral number with the same sign as x
; andf
is a ratio with the same type and sign as x
, and with absolute value less than 1
.toNumerator : Rational -> Basics.Int
Extract the numerator of the ratio in reduced form: the numerator and denominator have no common factor and the denominator is positive.
toDenominator : Rational -> Basics.Int
Extract the denominator of the ratio in reduced form: the numerator and denominator have no common factor and the denominator is positive.
truncate : Rational -> Basics.Int
truncate x
returns the integer nearest x
between zero and x
.
round : Rational -> Basics.Int
round x
returns the nearest integer to x
: the even integer if x
is equily distant between two integers.
ceiling : Rational -> Basics.Int
ceiling x
returns the least integer not less than x
.
floor : Rational -> Basics.Int
floor x
returns the greatest integer not greater than x
.
compare : Rational -> Rational -> Basics.Order
Compare two Rationals.
greaterThan : Rational -> Rational -> Basics.Bool
Compare two Rationals, greater than precidate.
lessThan : Rational -> Rational -> Basics.Bool
Compare two Rationals, less than precidate.
add : Rational -> Rational -> Rational
Add two Rationals.
subtract : Rational -> Rational -> Rational
Subtract one Rational from another.
multiply : Rational -> Rational -> Rational
Multiply two Rationals.
divide : Rational -> Rational -> Rational
Divide two Rationals.
power : Basics.Int -> Rational -> Rational
Rase Rational
to the power.
addBounded : Rational -> Rational -> Result Numeric.ArithmeticError.ArithmeticError Rational
Adds two Rationals while checking for Overflow
/Underflow
.
subtractBounded : Rational -> Rational -> Result Numeric.ArithmeticError.ArithmeticError Rational
Subtract one Rational from another while checking for Overflow
/Underflow
.
multiplyBounded : Rational -> Rational -> Result Numeric.ArithmeticError.ArithmeticError Rational
Multiply two Rationals while checking for Overflow
/Underflow
.
divideBounded : Rational -> Rational -> Result Numeric.ArithmeticError.ArithmeticError Rational
Divide two Rationals while checking for Overflow
/Underflow
.
powerBounded : Basics.Int -> Rational -> Result Numeric.ArithmeticError.ArithmeticError Rational
Rase Rational
to the power while checking for Overflow
/Underflow