Description
FULL PRODUCT VERSION :
java version "1.5.0_05"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_05-b05)
Java HotSpot(TM) Client VM (build 1.5.0_05-b05, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
2.6.11-6mdk #1 Tue Mar 22 16:04:32 CET 2005 i686 Intel(R) Pentium(R) 4 CPU 2.26GHz unknown GNU/Linux
A DESCRIPTION OF THE PROBLEM :
If you shift a BigInteger by Integer.MIN_VALUE, it throws StackOverflowError (probably because Integer.MIN_VALUE == -Integer.MIN_VALUE
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
BigInteger.ONE.shiftRight(Intger.MIN_VALUE)
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
BigInteger.ZERO
ACTUAL -
an Error: StackOverflowError
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.math.BigInteger;
public class BugShift{
public static void main(String[] args){
System.out.println(BigInteger.ONE.shiftRight(Integer.MIN_VALUE));
}
}
---------- END SOURCE ----------
java version "1.5.0_05"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_05-b05)
Java HotSpot(TM) Client VM (build 1.5.0_05-b05, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
2.6.11-6mdk #1 Tue Mar 22 16:04:32 CET 2005 i686 Intel(R) Pentium(R) 4 CPU 2.26GHz unknown GNU/Linux
A DESCRIPTION OF THE PROBLEM :
If you shift a BigInteger by Integer.MIN_VALUE, it throws StackOverflowError (probably because Integer.MIN_VALUE == -Integer.MIN_VALUE
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
BigInteger.ONE.shiftRight(Intger.MIN_VALUE)
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
BigInteger.ZERO
ACTUAL -
an Error: StackOverflowError
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.math.BigInteger;
public class BugShift{
public static void main(String[] args){
System.out.println(BigInteger.ONE.shiftRight(Integer.MIN_VALUE));
}
}
---------- END SOURCE ----------
Attachments
Issue Links
- duplicates
-
JDK-6590391 BigInteger.ONE.shiftLeft(Integer.MIN_VALUE) Recurses Infinitely
- Closed
- relates to
-
JDK-6910473 java.math.BigInteger.bitLength() may return negative "int" on large numbers
- Closed