[kaffe] Simple program shows strange results

Kevin D. Kissell kevink at mips.com
Thu Mar 6 07:33:01 PST 2003


Interestingly enough, if I run either an interpretive kaffe 1.0.7 
plus my MIPS patches, or an interpretive MIPS build of the
current kaffe.org CVS sources on a little-endian MIPS/Linux box 
(a MIPS "Malta" board with a 5Kc processor on it), I get::

[kevink at localhost BUGS]$ javac Test.java
[kevink at localhost BUGS]$ ls
Hello.class  Hello.java  Test.class  Test.java
[kevink at localhost BUGS]$ java Test
9.999999
x>pf: 9.999999 9.0
x pe pf =9.0 7.0 9.0

which looks to me to be your "correct" result.

So the problem may be unique to x86 platforms, and if so,
that vastly reduces the number of places one needs to look
for the problem.  It may be an x86 JIT bug, for example.
Could someone run the test on an interpretive-only x86
kaffe?

            Kevin K.

----- Original Message ----- 
From: "Ito Kazumitsu" <kaz at maczuka.gcd.org>
To: <kaffe at kaffe.org>
Sent: Monday, March 03, 2003 5:59 PM
Subject: [kaffe] Simple program shows strange results


> The following program:
> 
> public class Test {
>   public static void main(String[] args) {
>       float x = 0f;
> 
>       float pb = 15.0f;
>       float pc = 2.0f;
>       float pd = 6.0f;
>       float pe = 7.0f;
>       float pf = 9.0f;
>           
>       x = (1.0f - (pc / pd)) * pb;
>       System.err.println(x);
>       if (x < pe) {
>         System.err.println("x<pe: " + x + " " + pe);
>         x = pe;
>       }
>       else if (x > pf) {
>         System.err.println("x>pf: " + x + " " + pf);
>         x = pf;
>       }
>       System.err.println("x pe pf =" + x + " " + pe + " "+ pf);
>   }
> }
> 
> shows the following output when run with j2sdk1.4.0:
> 
> bash$ java Test
> 9.999999
> x>pf: 9.999999 9.0
> x pe pf =9.0 7.0 9.0
> 
> which is what I expect.  But when run with kaffe, it shows:
> 
> bash-2.05b$ java Test
> 9.999999
> x<pe: 0.0 7.0
> x pe pf =7.0 7.0 9.0
> 
> The kaffe version is
> 
> Engine: Just-in-time v3   Version: 1.1.x-cvs   Java Version: 1.1
> Configuration/Compilation options:
>   Compile date  : Sun Feb 23 11:17:00 JST 2003
>   Compile host  : ph.maczuka.gcd.org
>   Install prefix: /usr/local/kaffe
>   Thread system : unix-jthreads
>   CC            : gcc
>   CFLAGS        : -g -O2 -Wall -Wstrict-prototypes
>   LDFLAGS       : 
>   ChangeLog head: 2003-02-12 Dalibor Topic <robilad at yahoo.com>
> 
> By the way,  changing the said program as follows, that is
> changing the System.err.println(x) to System.err.println("x=" + x),
> I get expected output.
> 
> public class Test {
>   public static void main(String[] args) {
>       float x = 0f;
> 
>       float pb = 15.0f;
>       float pc = 2.0f;
>       float pd = 6.0f;
>       float pe = 7.0f;
>       float pf = 9.0f;
>           
>       x = (1.0f - (pc / pd)) * pb;
>       System.err.println("x=" + x);
>       if (x < pe) {
>         System.err.println("x<pe: " + x + " " + pe);
>         x = pe;
>       }
>       else if (x > pf) {
>         System.err.println("x>pf: " + x + " " + pf);
>         x = pf;
>       }
>       System.err.println("x pe pf =" + x + " " + pe + " "+ pf);
>   }
> }
> 
> bash-2.05b$ java Test
> x=9.999999
> x>pf: 9.999999 9.0
> x pe pf =9.0 7.0 9.0
> 
> I wonder what is happening.
> 
> _______________________________________________
> kaffe mailing list
> kaffe at kaffe.org
> http://kaffe.org/cgi-bin/mailman/listinfo/kaffe
> 




More information about the kaffe mailing list