This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libgcj/16122] New: gij - Incorrect result due to computations in extended precision on x86
- From: "debian-gcc at lists dot debian dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 21 Jun 2004 19:58:31 -0000
- Subject: [Bug libgcj/16122] New: gij - Incorrect result due to computations in extended precision on x86
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
[forwarded from http://bugs.debian.org/255525]
3.3.4 release and 3.4.1 branch, bug submitter writes:
Concerning the following Java source:
------------------------------------------------------------------
// $Id: test.java 3734 2004-06-21 15:36:52Z lefevre $
public class test {
public static void main(String[] args) throws Exception {
test t = new test();
t.doTest();
}
volatile double x, y, z, d;
public void doTest() {
x = 9007199254740994.0; /* 2^53 + 2 */
y = 1.0 - 1/65536.0;
z = x + y;
d = z - x;
System.out.println("z = " + z);
System.out.println("d = " + d);
}
}
------------------------------------------------------------------
I've compiled it with "gcj -C test.java" (GCC 3.3.4).
Both IBM's and Sun's JVM give the correct result:
greux:~/wd/src/fp> /global/greux/lefevre/IBMJava2-131/jre/bin/java test
z = 9.007199254740994E15
d = 0.0
greux:~/wd/src/fp> /usr/local/j2re1.4.1/bin/java test
z = 9.007199254740994E15
d = 0.0
but not gij:
greux:~/wd/src/fp> /usr/bin/gij test
z = 9.007199254740996E15
d = 2.0
gij should switch the FPU of the x86 processor
(Pentium III in my case) to rounding in double precision to avoid the
effect of the "double rounding" (you may find some information about
this effect here: <http://www.srware.com/linux_numerics.txt>).
--
Summary: gij - Incorrect result due to computations in extended
precision on x86
Product: gcc
Version: 3.4.1
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: libgcj
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: debian-gcc at lists dot debian dot org
CC: gcc-bugs at gcc dot gnu dot org,java-prs at gcc dot gnu
dot org
GCC host triplet: i486-linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16122