< prev index next >
jdk/src/java.base/share/classes/java/math/BigInteger.java
Print this page
*** 295,305 ****
* @param len the number of bytes to use.
* @throws NumberFormatException {@code val} is zero bytes long.
* @throws IndexOutOfBoundsException if the provided array offset and
* length would cause an index into the byte array to be
* negative or greater than or equal to the array length.
! * @since 1.9
*/
public BigInteger(byte[] val, int off, int len) {
if (val.length == 0) {
throw new NumberFormatException("Zero length BigInteger");
} else if ((off < 0) || (off >= val.length) || (len < 0) ||
--- 295,305 ----
* @param len the number of bytes to use.
* @throws NumberFormatException {@code val} is zero bytes long.
* @throws IndexOutOfBoundsException if the provided array offset and
* length would cause an index into the byte array to be
* negative or greater than or equal to the array length.
! * @since 9
*/
public BigInteger(byte[] val, int off, int len) {
if (val.length == 0) {
throw new NumberFormatException("Zero length BigInteger");
} else if ((off < 0) || (off >= val.length) || (len < 0) ||
*** 383,393 ****
* legal values (-1, 0, and 1), or {@code signum} is 0 and
* {@code magnitude} contains one or more non-zero bytes.
* @throws IndexOutOfBoundsException if the provided array offset and
* length would cause an index into the byte array to be
* negative or greater than or equal to the array length.
! * @since 1.9
*/
public BigInteger(int signum, byte[] magnitude, int off, int len) {
if (signum < -1 || signum > 1) {
throw(new NumberFormatException("Invalid signum value"));
} else if ((off < 0) || (len < 0) ||
--- 383,393 ----
* legal values (-1, 0, and 1), or {@code signum} is 0 and
* {@code magnitude} contains one or more non-zero bytes.
* @throws IndexOutOfBoundsException if the provided array offset and
* length would cause an index into the byte array to be
* negative or greater than or equal to the array length.
! * @since 9
*/
public BigInteger(int signum, byte[] magnitude, int off, int len) {
if (signum < -1 || signum > 1) {
throw(new NumberFormatException("Invalid signum value"));
} else if ((off < 0) || (len < 0) ||
*** 2422,2432 ****
* @throws ArithmeticException if {@code this} is negative. (The square
* root of a negative integer {@code val} is
* {@code (i * sqrt(-val))} where <i>i</i> is the
* <i>imaginary unit</i> and is equal to
* {@code sqrt(-1)}.)
! * @since 1.9
*/
public BigInteger sqrt() {
if (this.signum < 0) {
throw new ArithmeticException("Negative BigInteger");
}
--- 2422,2432 ----
* @throws ArithmeticException if {@code this} is negative. (The square
* root of a negative integer {@code val} is
* {@code (i * sqrt(-val))} where <i>i</i> is the
* <i>imaginary unit</i> and is equal to
* {@code sqrt(-1)}.)
! * @since 9
*/
public BigInteger sqrt() {
if (this.signum < 0) {
throw new ArithmeticException("Negative BigInteger");
}
*** 2445,2455 ****
* root of a negative integer {@code val} is
* {@code (i * sqrt(-val))} where <i>i</i> is the
* <i>imaginary unit</i> and is equal to
* {@code sqrt(-1)}.)
* @see #sqrt()
! * @since 1.9
*/
public BigInteger[] sqrtAndRemainder() {
BigInteger s = sqrt();
BigInteger r = this.subtract(s.square());
assert r.compareTo(BigInteger.ZERO) >= 0;
--- 2445,2455 ----
* root of a negative integer {@code val} is
* {@code (i * sqrt(-val))} where <i>i</i> is the
* <i>imaginary unit</i> and is equal to
* {@code sqrt(-1)}.)
* @see #sqrt()
! * @since 9
*/
public BigInteger[] sqrtAndRemainder() {
BigInteger s = sqrt();
BigInteger r = this.subtract(s.square());
assert r.compareTo(BigInteger.ZERO) >= 0;
< prev index next >