Rational
Rational =
object
Defined in: packages/math-numbers/src/rational/rational-types.ts:15
An exact rational, stored as a pair of bigints.
This is the arithmetic layer for ℚ: plain data plus free functions, with no class and no wrapper around the numerator and denominator. Every operation here is real work — cross-multiplication, sign normalisation, reduction by the greatest common divisor — which is what earns it a function rather than an operator.
Invariant: denominator > 0. The sign lives entirely in the numerator,
so comparison never has to inspect the denominator’s sign. Values are not
necessarily reduced; ratReduce does that, and isReduced
records whether it has been done.
Properties
Section titled “Properties”denominator
Section titled “denominator”denominator:
bigint
Defined in: packages/math-numbers/src/rational/rational-types.ts:19
Always strictly positive.
numerator
Section titled “numerator”numerator:
bigint
Defined in: packages/math-numbers/src/rational/rational-types.ts:16
reduced
Section titled “reduced”reduced:
boolean
Defined in: packages/math-numbers/src/rational/rational-types.ts:22
true when gcd(|numerator|, denominator) = 1 is known to hold.