Skip to content

rationalAdd

rationalAdd(a, b): Rational

Defined in: packages/math-numbers/src/rational/rational-add.ts:13

a + b, as (a.n·b.d + b.n·a.d) / (a.d·b.d).

The denominators are divided by their GCD first, so the intermediate product stays as small as the operands allow. Without it the denominator of a long sum grows as the product of every denominator seen.

Readonly<Rational>

Readonly<Rational>

Rational