-
Bug
-
Resolution: Fixed
-
P4
-
1.3.1
-
beta2
-
x86
-
windows_98
-
Verified
Name: tb29552 Date: 05/24/2001
/* Integer versus Long
In class java.math.BigInteger the private attribute
"SMALL_PRIME_PRODUCT" is initialized to
3*5*7*11*13*17*19*23*29*31*37*41 which is interpreted as integer
multiplication, leading to a value of 1685106581 which of course
is wrong (much too less)!
A simple "L" behind the 3 (for example) would make the compiler
interpreting the expression as long, leading to the correct value
of 152125131763605.
This bug makes the method "smallPrime()" reject a lot of primes
in its simple prime test which are in fact correct primes. This
makes the construction of prime big integers much slower!
The following code illustrates the bug:
System.out.println(BigInteger.valueOf(3*5*7*11*13*17*19*23*29*31*37*41));
Code working correctly (added "L" behind 3):
System.out.println(BigInteger.valueOf(3L*5*7*11*13*17*19*23*29*31*37*41));
*/
public class IVL {
public static void main(String[] args) {
//The following code reproduces the bug:
System.out.println
(java.math.BigInteger.valueOf
(3 * 5 * 7 * 11 * 13 * 17 * 19 * 23 * 29 * 31 * 37 * 41));
//Code working correctly (added "L" behind 3):
System.out.println
(java.math.BigInteger.valueOf
(3L * 5 * 7 * 11 * 13 * 17 * 19 * 23 * 29 * 31 * 37 * 41));
}
}
(Review ID: 124943)
======================================================================
- relates to
-
JDK-4403532 Compiler does not follow JLS section 4.2.2 when folding constant expressions
-
- Closed
-