code: public BigDecimal compute(int scale, RoundingMode mode) {
      return numerator.divide(denominator, scale, mode).stripTrailingZeros();
    }
docs: Divide the numerator by the denominator, using the given scale and
  rounding mode, and return the resulting decimal number.