operator + method

BigDecimal operator +(
  1. BigDecimal other
)

Adds another BigDecimal to this one.

Implementation

BigDecimal operator +(BigDecimal other) {
  int maxScale = _scale > other._scale ? _scale : other._scale;
  BigDecimal a = setScale(maxScale);
  BigDecimal b = other.setScale(maxScale);

  BigInt result = a._unscaledValue + b._unscaledValue;
  return BigDecimal._(result, maxScale);
}