Name: yyT116575 Date: 03/26/2001
I have reproduced this exact same problem in JBuilder 3.5 using JDK 1.2.2,
Microsoft Internet Explorer using JVM 3234, Netscape 4.7 using Java 1.1.5, and
Netscape 6.0 using JRE version 1.3.0_01 Java HotSpot(TM) Client VM, so it is
pretty widespread
This is really easy to reproduce, just execute the following code:
>
public class doubletest {
public static void main(String args[]) {
double a = 1.2E-5;
double b = 1.0E-6;
double c = a + b;
double d = 1.2E-5 + 1.0E-6;
System.out.println("a: " + new Double(a).toString());
System.out.println("b: " + new Double(b).toString());
System.out.println("c: " + new Double(c).toString());
System.out.println("d: " + new Double(d).toString());
}
}
>
The output you get is:
>
a: 1.2E-5
b: 1.0E-6
c: 1.3000000000000001E-5
d: 1.3000000000000001E-5
>
This is only one example. I have seen this for many other values, but not all
values.
There are some bug reports that reference similar problems, but these all site
the cause as a JIT compilier, and I don't think the 4 different runtime systems
listed above use the same JIT compiler.
(Review ID: 119519)
======================================================================
- relates to
-
JDK-4430070 double and float not calculating correctly
-
- Closed
-