Strange double calculation result with JDK1.4.2

Hi,

I’ve written a small benchmark to test the processing power of the new Sharp Zaurus PDA models.http://www.alterna.tv/zjb/Zjb.java

Then I wanted to compare the result with my workstation, with JDK 1.4.2 Beta. And I was really surprised to discover that the Pi calculation was giving a wrong result: Pi=3.1413934230804443!

This only happens when running the whole program AND with JDK1.4.2.
I had no problems when:

  • using other JDK: 1.4.1, 1.4.1_01, 1.3.1_01, 1.1.8
  • using other platforms: PC, Zaurus
  • extracting the Pi calculation fragment, with/without previous code…

So it must be:
0) A bug in my code, but I can’t pinpoint it.

  1. A problem in my workstation configuration. Apart from setting up JDK1.4.2, nothing new has happened recently.
  2. A bug in the platform/OS. Could a new Win2K hotfix have broken a fix for a hardware problem, and Sun coincidentaly has removed the support from the JVM :stuck_out_tongue: My platform is a Win2K SP3 2xPII 350MHz.
  3. A normal bug encountered in Beta software. Never play with Beta software keep saying my mother :wink:
  4. An alien cause not listed in software development courses…

Could someone with a 1.4.2 JDK setup try my code and check the Pi value?
There’s no need reporting the problem to Sun if it’s not point 2) or 3).

As a bonus, you’ll can compare the performance of your workstation with a Zaurus SL-5500 PDA running Jeode http://www.alterna.tv/zjb/zjb-SL-5500.png or Sun Personal Profile http://www.alterna.tv/zjb/zjb-SL-5500-Sun.png.

Check the strictfp keyword:
http://java.sun.com/docs/books/jls/second_edition/html/expressions.doc.html#249198
I’m not sure if it will fix PI for you but it could explain your problem and how it could be legal.

Hi leknor,

Thanks. I’ve forgotten to say that I had already tried the strictfp modifier and it does not help: I got the same result on my workstation…

That’s really strange, because I can switch the JVM in Eclipse (or on the command line) at will, and I get a different result only on that test! And on the Zaurus with FP emulator, I get it right!

But I have no another PC where to try another JDK1.4.2 setup and check if it’s a configuration problem… :stuck_out_tongue:

OK, I’ve found another PC where to setup JRE 1.4.2Beta. The problem still occurs and seems to be related to the new JVM (Sun Bugs #4843257 & 4828693).

Conclusion: don’t use the 1.4.2Beta with intensive float calculations!