src/share/classes/java/math/BigInteger.java
Print this page
*** 2049,2067 ****
* this method performs a right shift.
* (Computes <tt>floor(this * 2<sup>n</sup>)</tt>.)
*
* @param n shift distance, in bits.
* @return {@code this << n}
* @see #shiftRight
*/
public BigInteger shiftLeft(int n) {
if (signum == 0)
return ZERO;
if (n==0)
return this;
! if (n<0)
return shiftRight(-n);
int nInts = n >>> 5;
int nBits = n & 0x1f;
int magLen = mag.length;
int newMag[] = null;
--- 2049,2074 ----
* this method performs a right shift.
* (Computes <tt>floor(this * 2<sup>n</sup>)</tt>.)
*
* @param n shift distance, in bits.
* @return {@code this << n}
+ * @throws ArithmeticException if the shift distance is {@code
+ * Integer.MIN_VALUE}.
* @see #shiftRight
*/
public BigInteger shiftLeft(int n) {
if (signum == 0)
return ZERO;
if (n==0)
return this;
! if (n<0) {
! if (n == Integer.MIN_VALUE) {
! throw new ArithmeticException("Shift distance of Integer.MIN_VALUE not supported.");
! } else {
return shiftRight(-n);
+ }
+ }
int nInts = n >>> 5;
int nBits = n & 0x1f;
int magLen = mag.length;
int newMag[] = null;
*** 2095,2111 ****
* negative, in which case this method performs a left shift.
* (Computes <tt>floor(this / 2<sup>n</sup>)</tt>.)
*
* @param n shift distance, in bits.
* @return {@code this >> n}
* @see #shiftLeft
*/
public BigInteger shiftRight(int n) {
if (n==0)
return this;
! if (n<0)
return shiftLeft(-n);
int nInts = n >>> 5;
int nBits = n & 0x1f;
int magLen = mag.length;
int newMag[] = null;
--- 2102,2125 ----
* negative, in which case this method performs a left shift.
* (Computes <tt>floor(this / 2<sup>n</sup>)</tt>.)
*
* @param n shift distance, in bits.
* @return {@code this >> n}
+ * @throws ArithmeticException if the shift distance is {@code
+ * Integer.MIN_VALUE}.
* @see #shiftLeft
*/
public BigInteger shiftRight(int n) {
if (n==0)
return this;
! if (n<0) {
! if (n == Integer.MIN_VALUE) {
! throw new ArithmeticException("Shift distance of Integer.MIN_VALUE not supported.");
! } else {
return shiftLeft(-n);
+ }
+ }
int nInts = n >>> 5;
int nBits = n & 0x1f;
int magLen = mag.length;
int newMag[] = null;