operator + method

BigRational operator +(
  1. BigRational other
)

Adds the given BigRational to this BigRational and returns the result.

other The BigRational to be added. returns A new BigRational representing the sum of this BigRational and the given BigRational.

Implementation

BigRational operator +(BigRational other) {
  final BigInt multiple = _lcm(denominator, other.denominator);
  BigInt a = multiple ~/ denominator;
  BigInt b = multiple ~/ other.denominator;

  a = numerator * a;
  b = other.numerator * b;

  return _reduce(a + b, multiple);
}