src/share/classes/java/math/BigInteger.java

Print this page

        

*** 476,486 **** this(val, 10); } /** * Constructs a randomly generated BigInteger, uniformly distributed over ! * the range {@code 0} to (2<sup>{@code numBits}</sup> - 1), inclusive. * The uniformity of the distribution assumes that a fair source of random * bits is provided in {@code rnd}. Note that this constructor always * constructs a non-negative BigInteger. * * @param numBits maximum bitLength of the new BigInteger. --- 476,486 ---- this(val, 10); } /** * Constructs a randomly generated BigInteger, uniformly distributed over ! * the range 0 to (2<sup>{@code numBits}</sup> - 1), inclusive. * The uniformity of the distribution assumes that a fair source of random * bits is provided in {@code rnd}. Note that this constructor always * constructs a non-negative BigInteger. * * @param numBits maximum bitLength of the new BigInteger.
*** 1330,1340 **** /** * Returns a BigInteger whose value is {@code (this / val)}. * * @param val value by which this BigInteger is to be divided. * @return {@code this / val} ! * @throws ArithmeticException {@code val==0} */ public BigInteger divide(BigInteger val) { MutableBigInteger q = new MutableBigInteger(), a = new MutableBigInteger(this.mag), b = new MutableBigInteger(val.mag); --- 1330,1340 ---- /** * Returns a BigInteger whose value is {@code (this / val)}. * * @param val value by which this BigInteger is to be divided. * @return {@code this / val} ! * @throws ArithmeticException if {@code val} is zero. */ public BigInteger divide(BigInteger val) { MutableBigInteger q = new MutableBigInteger(), a = new MutableBigInteger(this.mag), b = new MutableBigInteger(val.mag);
*** 1350,1360 **** * @param val value by which this BigInteger is to be divided, and the * remainder computed. * @return an array of two BigIntegers: the quotient {@code (this / val)} * is the initial element, and the remainder {@code (this % val)} * is the final element. ! * @throws ArithmeticException {@code val==0} */ public BigInteger[] divideAndRemainder(BigInteger val) { BigInteger[] result = new BigInteger[2]; MutableBigInteger q = new MutableBigInteger(), a = new MutableBigInteger(this.mag), --- 1350,1360 ---- * @param val value by which this BigInteger is to be divided, and the * remainder computed. * @return an array of two BigIntegers: the quotient {@code (this / val)} * is the initial element, and the remainder {@code (this % val)} * is the final element. ! * @throws ArithmeticException if {@code val} is zero. */ public BigInteger[] divideAndRemainder(BigInteger val) { BigInteger[] result = new BigInteger[2]; MutableBigInteger q = new MutableBigInteger(), a = new MutableBigInteger(this.mag),
*** 1369,1379 **** * Returns a BigInteger whose value is {@code (this % val)}. * * @param val value by which this BigInteger is to be divided, and the * remainder computed. * @return {@code this % val} ! * @throws ArithmeticException {@code val==0} */ public BigInteger remainder(BigInteger val) { MutableBigInteger q = new MutableBigInteger(), a = new MutableBigInteger(this.mag), b = new MutableBigInteger(val.mag); --- 1369,1379 ---- * Returns a BigInteger whose value is {@code (this % val)}. * * @param val value by which this BigInteger is to be divided, and the * remainder computed. * @return {@code this % val} ! * @throws ArithmeticException if {@code val} is zero. */ public BigInteger remainder(BigInteger val) { MutableBigInteger q = new MutableBigInteger(), a = new MutableBigInteger(this.mag), b = new MutableBigInteger(val.mag);
*** 1545,1555 **** * differs from {@code remainder} in that it always returns a * <i>non-negative</i> BigInteger. * * @param m the modulus. * @return {@code this mod m} ! * @throws ArithmeticException {@code m <= 0} * @see #remainder */ public BigInteger mod(BigInteger m) { if (m.signum <= 0) throw new ArithmeticException("BigInteger: modulus not positive"); --- 1545,1555 ---- * differs from {@code remainder} in that it always returns a * <i>non-negative</i> BigInteger. * * @param m the modulus. * @return {@code this mod m} ! * @throws ArithmeticException {@code m} &le; 0 * @see #remainder */ public BigInteger mod(BigInteger m) { if (m.signum <= 0) throw new ArithmeticException("BigInteger: modulus not positive");
*** 1564,1574 **** * method permits negative exponents.) * * @param exponent the exponent. * @param m the modulus. * @return <tt>this<sup>exponent</sup> mod m</tt> ! * @throws ArithmeticException {@code m <= 0} * @see #modInverse */ public BigInteger modPow(BigInteger exponent, BigInteger m) { if (m.signum <= 0) throw new ArithmeticException("BigInteger: modulus not positive"); --- 1564,1576 ---- * method permits negative exponents.) * * @param exponent the exponent. * @param m the modulus. * @return <tt>this<sup>exponent</sup> mod m</tt> ! * @throws ArithmeticException {@code m} &le; 0 or the exponent is ! * negative and this BigInteger is not <i>relatively ! * prime</i> to {@code m}. * @see #modInverse */ public BigInteger modPow(BigInteger exponent, BigInteger m) { if (m.signum <= 0) throw new ArithmeticException("BigInteger: modulus not positive");
*** 2013,2023 **** /** * Returns a BigInteger whose value is {@code (this}<sup>-1</sup> {@code mod m)}. * * @param m the modulus. * @return {@code this}<sup>-1</sup> {@code mod m}. ! * @throws ArithmeticException {@code m <= 0}, or this BigInteger * has no multiplicative inverse mod m (that is, this BigInteger * is not <i>relatively prime</i> to m). */ public BigInteger modInverse(BigInteger m) { if (m.signum != 1) --- 2015,2025 ---- /** * Returns a BigInteger whose value is {@code (this}<sup>-1</sup> {@code mod m)}. * * @param m the modulus. * @return {@code this}<sup>-1</sup> {@code mod m}. ! * @throws ArithmeticException {@code m} &le; 0, or this BigInteger * has no multiplicative inverse mod m (that is, this BigInteger * is not <i>relatively prime</i> to m). */ public BigInteger modInverse(BigInteger m) { if (m.signum != 1)
*** 2447,2457 **** // Primality Testing /** * Returns {@code true} if this BigInteger is probably prime, * {@code false} if it's definitely composite. If ! * {@code certainty} is {@code <= 0}, {@code true} is * returned. * * @param certainty a measure of the uncertainty that the caller is * willing to tolerate: if the call returns {@code true} * the probability that this BigInteger is prime exceeds --- 2449,2459 ---- // Primality Testing /** * Returns {@code true} if this BigInteger is probably prime, * {@code false} if it's definitely composite. If ! * {@code certainty} is &le; 0, {@code true} is * returned. * * @param certainty a measure of the uncertainty that the caller is * willing to tolerate: if the call returns {@code true} * the probability that this BigInteger is prime exceeds