Lines Matching defs:divisor

130  * <tr><td>Divide</td><td>dividend.scale() - divisor.scale()</td>
1353 * divisor)}, and whose scale is as specified. If rounding must
1360 * @param divisor value by which this {@code BigDecimal} is to be divided.
1363 * @return {@code this / divisor}
1364 * @throws ArithmeticException if {@code divisor} is zero,
1379 public BigDecimal divide(BigDecimal divisor, int scale, int roundingMode) {
1388 * Rescale dividend or divisor (whichever can be "upscaled" to
1393 if (checkScale((long)scale + divisor.scale) > this.scale)
1394 dividend = this.setScale(scale + divisor.scale, ROUND_UNNECESSARY);
1396 divisor = divisor.setScale(checkScale((long)this.scale - scale),
1399 divisor.intCompact, divisor.intVal,
1404 * Internally used for division operation. The dividend and divisor are
1498 * divisor)}, and whose scale is as specified. If rounding must
1502 * @param divisor value by which this {@code BigDecimal} is to be divided.
1505 * @return {@code this / divisor}
1506 * @throws ArithmeticException if {@code divisor} is zero,
1512 public BigDecimal divide(BigDecimal divisor, int scale, RoundingMode roundingMode) {
1513 return divide(divisor, scale, roundingMode.oldMode);
1518 * divisor)}, and whose scale is {@code this.scale()}. If
1525 * @param divisor value by which this {@code BigDecimal} is to be divided.
1527 * @return {@code this / divisor}
1528 * @throws ArithmeticException if {@code divisor==0}, or
1543 public BigDecimal divide(BigDecimal divisor, int roundingMode) {
1544 return this.divide(divisor, scale, roundingMode);
1549 * divisor)}, and whose scale is {@code this.scale()}. If
1553 * @param divisor value by which this {@code BigDecimal} is to be divided.
1555 * @return {@code this / divisor}
1556 * @throws ArithmeticException if {@code divisor==0}, or
1562 public BigDecimal divide(BigDecimal divisor, RoundingMode roundingMode) {
1563 return this.divide(divisor, scale, roundingMode.oldMode);
1568 * divisor)}, and whose preferred scale is {@code (this.scale() -
1569 * divisor.scale())}; if the exact quotient cannot be
1573 * @param divisor value by which this {@code BigDecimal} is to be divided.
1576 * @return {@code this / divisor}
1580 public BigDecimal divide(BigDecimal divisor) {
1584 if (divisor.signum() == 0) { // x/0
1591 int preferredScale = saturateLong((long)this.scale - divisor.scale);
1599 divisor.inflate();
1601 * If the quotient this/divisor has a terminating decimal
1609 (long)Math.ceil(10.0*divisor.precision()/3.0),
1614 quotient = this.divide(divisor, mc);
1636 * divisor)}, with rounding according to the context settings.
1638 * @param divisor value by which this {@code BigDecimal} is to be divided.
1640 * @return {@code this / divisor}, rounded as necessary.
1647 public BigDecimal divide(BigDecimal divisor, MathContext mc) {
1650 return divide(divisor);
1653 long preferredScale = (long)dividend.scale - divisor.scale;
1666 if (divisor.signum() == 0) { // x/0
1675 // Normalize dividend & divisor so that both fall into [0.1, 0.999...]
1677 int yscale = divisor.precision();
1680 divisor = new BigDecimal(divisor.intVal, divisor.intCompact,
1682 if (dividend.compareMagnitude(divisor) > 0) // satisfy constraint (b)
1683 yscale = divisor.scale -= 1; // [that is, divisor *= 10]
1693 divisor = divisor.setScale(checkScale((long)xscale - mcp),
1696 divisor.intCompact, divisor.intVal,
1707 * of the quotient {@code (this / divisor)} rounded down. The
1709 * divisor.scale())}.
1711 * @param divisor value by which this {@code BigDecimal} is to be divided.
1712 * @return The integer part of {@code this / divisor}.
1713 * @throws ArithmeticException if {@code divisor==0}
1716 public BigDecimal divideToIntegralValue(BigDecimal divisor) {
1718 int preferredScale = saturateLong((long)this.scale - divisor.scale);
1719 if (this.compareMagnitude(divisor) < 0) {
1720 // much faster when this << divisor
1724 if(this.signum() == 0 && divisor.signum() != 0)
1731 (long)Math.ceil(10.0*divisor.precision()/3.0) +
1732 Math.abs((long)this.scale() - divisor.scale()) + 2,
1734 BigDecimal quotient = this.divide(divisor, new MathContext(maxDigits,
1750 * of {@code (this / divisor)}. Since the integer part of the
1754 * {@code (this.scale() - divisor.scale())}. An
1759 * @param divisor value by which this {@code BigDecimal} is to be divided.
1761 * @return The integer part of {@code this / divisor}.
1762 * @throws ArithmeticException if {@code divisor==0}
1768 public BigDecimal divideToIntegralValue(BigDecimal divisor, MathContext mc) {
1770 (this.compareMagnitude(divisor) < 0) ) // zero result
1771 return divideToIntegralValue(divisor);
1774 int preferredScale = saturateLong((long)this.scale - divisor.scale);
1778 * remainder has absolute value less than the divisor, the
1784 divide(divisor, new MathContext(mc.precision, RoundingMode.DOWN));
1790 * the computed remainder will be less than the divisor.
1792 BigDecimal product = result.multiply(divisor);
1794 // |dividend-product| < |divisor|.
1795 if (this.subtract(product).compareMagnitude(divisor) >= 0) {
1820 * Returns a {@code BigDecimal} whose value is {@code (this % divisor)}.
1823 * {@code this.subtract(this.divideToIntegralValue(divisor).multiply(divisor))}.
1827 * @param divisor value by which this {@code BigDecimal} is to be divided.
1828 * @return {@code this % divisor}.
1829 * @throws ArithmeticException if {@code divisor==0}
1832 public BigDecimal remainder(BigDecimal divisor) {
1833 BigDecimal divrem[] = this.divideAndRemainder(divisor);
1840 * divisor)}, with rounding according to the context settings.
1847 * {@code this.subtract(this.divideToIntegralValue(divisor,
1848 * mc).multiply(divisor))}. Note that this is not the modulo
1851 * @param divisor value by which this {@code BigDecimal} is to be divided.
1853 * @return {@code this % divisor}, rounded as necessary.
1854 * @throws ArithmeticException if {@code divisor==0}
1857 * {@literal >} 0 and the result of {@code this.divideToIntgralValue(divisor)} would
1862 public BigDecimal remainder(BigDecimal divisor, MathContext mc) {
1863 BigDecimal divrem[] = this.divideAndRemainder(divisor, mc);
1877 * @param divisor value by which this {@code BigDecimal} is to be divided,
1882 * @throws ArithmeticException if {@code divisor==0}
1887 public BigDecimal[] divideAndRemainder(BigDecimal divisor) {
1891 result[0] = this.divideToIntegralValue(divisor);
1892 result[1] = this.subtract(result[0].multiply(divisor));
1907 * @param divisor value by which this {@code BigDecimal} is to be divided,
1913 * @throws ArithmeticException if {@code divisor==0}
1916 * {@literal >} 0 and the result of {@code this.divideToIntgralValue(divisor)} would
1922 public BigDecimal[] divideAndRemainder(BigDecimal divisor, MathContext mc) {
1924 return divideAndRemainder(divisor);
1929 result[0] = lhs.divideToIntegralValue(divisor, mc);
1930 result[1] = lhs.subtract(result[0].multiply(divisor));