[Sablevm-developer] Bug#255524: sablevm: Incorrect result due to computations in extended precision
Brought to you by:
egagnon
|
From: Vincent L. <vi...@vi...> - 2004-06-21 16:23:19
|
Package: sablevm
Version: 1.1.5-1
Severity: normal
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 SableVM:
greux:~/wd/src/fp> /usr/bin/java-sablevm test
z = 9.007199254740996E15
d = 2.0
SableVM 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>).
-- System Information:
Debian Release: testing/unstable
APT prefers unstable
APT policy: (500, 'unstable'), (500, 'testing')
Architecture: i386 (i686)
Kernel: Linux 2.6.6
Locale: LANG=POSIX, LC_CTYPE=en_US.ISO8859-1
Versions of packages sablevm depends on:
ii java-common 0.22 Base of all Java packages
ii libc6 2.3.2.ds1-13 GNU C Library: Shared libraries an
ii libpopt0 1.7-4 lib for parsing cmdline parameters
ii libsablevm1 1.1.5-1 Free implementation of JVM second
ii unzip 5.51-2 De-archiver for .zip files
-- no debconf information
|