Exact rational number arithmetic, homed on the Rational class.
Literal syntax: 1/3, -2/7. The generic operators dispatch rational
operands through the type ops; / promotes inexact int division.
/Divide numbers; integer division produces rationals when not exact.
Parameters:
NUMBER — Numbers to divideReturns: NUMBER — Quotient
Rational(Rational rational? x)Test whether a value is a rational number or integer.
Parameters:
ANY — Value to testReturns: BOOL — True if x is rational or integer
(Rational exact? x)Test whether a value is an exact number.
Parameters:
ANY — Value to testReturns: BOOL — True if x is exact (rational or integer)
(Rational numerator x)Return the numerator of a rational number.
Parameters:
RATIONAL|INT — Rational or integerReturns: INT — Numerator of the rational, or the integer itself
(Rational denominator x)Return the denominator of a rational number.
Parameters:
RATIONAL|INT — Rational or integerReturns: INT — Denominator of the rational, or 1 for integers
(Rational + a b)Add two rationals (ints coerce).
Parameters:
RATIONAL|INT — First operandRATIONAL|INT — Second operandReturns: RATIONAL|INT — Sum, reduced to lowest terms
(Rational - a b)Subtract two rationals (ints coerce).
Parameters:
RATIONAL|INT — First operandRATIONAL|INT — Second operandReturns: RATIONAL|INT — Difference, reduced to lowest terms
(Rational * a b)Multiply two rationals (ints coerce).
Parameters:
RATIONAL|INT — First operandRATIONAL|INT — Second operandReturns: RATIONAL|INT — Product, reduced to lowest terms
(Rational / a b)Divide two rationals (ints coerce).
Parameters:
RATIONAL|INT — DividendRATIONAL|INT — DivisorReturns: RATIONAL|INT — Quotient, reduced to lowest terms
(Rational < a b)Test whether a is less than b (ints coerce).
Parameters:
RATIONAL|INT — Left operandRATIONAL|INT — Right operandReturns: BOOL — True if a < b
(Rational = a b)Test whether a equals b (ints coerce).
Parameters:
RATIONAL|INT — Left operandRATIONAL|INT — Right operandReturns: BOOL — True if a equals b