FULL PRODUCT VERSION :
java version " 1.8.0-ea "
Java(TM) SE Runtime Environment (build 1.8.0-ea-b99)
Java HotSpot(TM) 64-Bit Server VM (build 25.0-b41, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux kisa 3.8.0-26-generic #38-Ubuntu SMP Mon Jun 17 21:43:33 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
Now it easy to create a BigInteger object so large that its methods work incorrectly.
This bug report is about methods BigInteger.doubleValue() and BigInteger.floatValue().
They may return <0.0> on such an object,
I expect that either they return <Infinity> or construction of such an object throws ArithemticException.
This bug is related to
JDK-8011942 : BigInteger returns an int for bitLength()
JDK-6910473 : java.math.BigInteger.bitLength() may return negative " int " on large numbers
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile attached test code and run it.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
ArithmeticException in shiftLeft method
or
bi.floatValue() = Infinity
bi.doubleValue() = Infinity
ACTUAL -
bi.floatValue() = 0.0
bi.doubleValue() = 0.0
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class DoubleValueTest {
public static void main(String[] args) {
BigInteger bi = BigInteger.valueOf(2).shiftLeft(Integer.MAX_VALUE);
System.out.println( " bi.floatValue() = " + bi.floatValue());
System.out.println( " bi.doubleValue() = " + bi.doubleValue());
}
}
---------- END SOURCE ----------
java version " 1.8.0-ea "
Java(TM) SE Runtime Environment (build 1.8.0-ea-b99)
Java HotSpot(TM) 64-Bit Server VM (build 25.0-b41, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux kisa 3.8.0-26-generic #38-Ubuntu SMP Mon Jun 17 21:43:33 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
Now it easy to create a BigInteger object so large that its methods work incorrectly.
This bug report is about methods BigInteger.doubleValue() and BigInteger.floatValue().
They may return <0.0> on such an object,
I expect that either they return <Infinity> or construction of such an object throws ArithemticException.
This bug is related to
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile attached test code and run it.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
ArithmeticException in shiftLeft method
or
bi.floatValue() = Infinity
bi.doubleValue() = Infinity
ACTUAL -
bi.floatValue() = 0.0
bi.doubleValue() = 0.0
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class DoubleValueTest {
public static void main(String[] args) {
BigInteger bi = BigInteger.valueOf(2).shiftLeft(Integer.MAX_VALUE);
System.out.println( " bi.floatValue() = " + bi.floatValue());
System.out.println( " bi.doubleValue() = " + bi.doubleValue());
}
}
---------- END SOURCE ----------
- relates to
-
JDK-8027595 Enable BigInteger overflow tests in JTREG
- Closed
-
JDK-6910473 java.math.BigInteger.bitLength() may return negative "int" on large numbers
- Closed