Please run the following test program on Linux or Windows using default
client VM.
The test program just calcucates "(2.0 * d1 * d2) - d1" 2000 times, where both
d1 and d2 are constants.
On my machines(RedHat Advanced Server 2.1 and Windows XP), the result is 0.0
while i is from 0 to 1498. But once i exceeds 1498, the result becomes -0.0.
I think that the same result(zero) should be always returned regardless of
the number of repeat.
public class t {
static double d1 = 1.0E-323;
static double d2 = 0.3889650226834289;
public static void main(String[] args) throws Exception {
for (int i = 0; i < 2000; i++) {
test(i);
}
}
static void test(int counter) {
double diff = (2.0 * d1 * d2) - d1;
if (diff == 0.0 && 1/diff < 0.0) {
System.out.println(counter + ": " + diff);
}
}
/******************************************************************************
The bug was not reproducible with the following code.
public static void main(String[] args) throws Exception {
for (int i = 0; i < 2000; i++) {
double diff = (2.0 * d1 * d2) - d1;
if (diff == 0.0 && 1/diff < 0.0) {
System.out.println(i + ": " + diff);
}
}
}
*******************************************************************************/
}
I happened to find this bug when one of our regression test programs failed
on Linux and Windows. The test program always passes on Solaris.
As far as I tested, this bug was reproducible with 1.4.2FCS, 1.5.0b22, b28,
and b29 using clint VM on Linux or Windows.
It was not reproducible
on Solaris regardless of VM setting(default(client), -server, -Xint etc)
on Linux or Windows using "-Xint" or "-server"
Output of the test program on my Linux machine:
1499: -0.0
1500: -0.0
1501: -0.0
1502: -0.0
1503: -0.0
...
1995: -0.0
1996: -0.0
1997: -0.0
1998: -0.0
1999: -0.0
client VM.
The test program just calcucates "(2.0 * d1 * d2) - d1" 2000 times, where both
d1 and d2 are constants.
On my machines(RedHat Advanced Server 2.1 and Windows XP), the result is 0.0
while i is from 0 to 1498. But once i exceeds 1498, the result becomes -0.0.
I think that the same result(zero) should be always returned regardless of
the number of repeat.
public class t {
static double d1 = 1.0E-323;
static double d2 = 0.3889650226834289;
public static void main(String[] args) throws Exception {
for (int i = 0; i < 2000; i++) {
test(i);
}
}
static void test(int counter) {
double diff = (2.0 * d1 * d2) - d1;
if (diff == 0.0 && 1/diff < 0.0) {
System.out.println(counter + ": " + diff);
}
}
/******************************************************************************
The bug was not reproducible with the following code.
public static void main(String[] args) throws Exception {
for (int i = 0; i < 2000; i++) {
double diff = (2.0 * d1 * d2) - d1;
if (diff == 0.0 && 1/diff < 0.0) {
System.out.println(i + ": " + diff);
}
}
}
*******************************************************************************/
}
I happened to find this bug when one of our regression test programs failed
on Linux and Windows. The test program always passes on Solaris.
As far as I tested, this bug was reproducible with 1.4.2FCS, 1.5.0b22, b28,
and b29 using clint VM on Linux or Windows.
It was not reproducible
on Solaris regardless of VM setting(default(client), -server, -Xint etc)
on Linux or Windows using "-Xint" or "-server"
Output of the test program on my Linux machine:
1499: -0.0
1500: -0.0
1501: -0.0
1502: -0.0
1503: -0.0
...
1995: -0.0
1996: -0.0
1997: -0.0
1998: -0.0
1999: -0.0
- relates to
-
JDK-4959974 PIT regression: java/text/Format/NumberRoundTrip.java failed
-
- Closed
-