code: public BigDecimal compute(RoundingMode mode) {
      int scale = numerator.precision() + denominator.precision();
      scale = Math.max(MIN_SCALE, Math.min(MAX_SCALE, scale));
      return numerator.divide(denominator, scale, mode).stripTrailingZeros();
    }
docs: Divide the numerator by the denominator and return the resulting
  decimal number.