Returns the result of dividing p by q, rounding using the specified RoundingMode. @throws ArithmeticException if q == 0, or if mode == UNNECESSARY and a is not an integer multiple of b
(BigInteger p, BigInteger q, RoundingMode mode)
| 315 | */ |
| 316 | |
| 317 | @GwtIncompatible // TODO |
| 318 | public static BigInteger divide(BigInteger p, BigInteger q, RoundingMode mode) { |
| 319 | BigDecimal pDec = new BigDecimal(p); |
| 320 | BigDecimal qDec = new BigDecimal(q); |
| 321 | return pDec.divide(qDec, 0, mode).toBigIntegerExact(); |
| 322 | } |
| 323 | |
| 324 | /** |
| 325 | * Returns {@code n!}, that is, the product of the first {@code n} positive integers, or {@code 1} |