From owner-freebsd-java Fri Jul 9 15: 2: 6 1999 Delivered-To: freebsd-java@freebsd.org Received: from ThinkPad.nowhere.local (dieringe.dialup.fu-berlin.de [160.45.221.216]) by hub.freebsd.org (Postfix) with ESMTP id 1F66214C44 for ; Fri, 9 Jul 1999 15:01:49 -0700 (PDT) (envelope-from martin@dieringe.dialup.fu-berlin.de) Received: from localhost (localhost [127.0.0.1]) by ThinkPad.nowhere.local (8.9.3/8.9.2) with ESMTP id AAA44687; Sat, 10 Jul 1999 00:01:41 +0200 (CEST) (envelope-from martin@dieringe.dialup.fu-berlin.de) Date: Sat, 10 Jul 1999 00:01:41 +0200 (CEST) From: Martin Dieringer X-Sender: martin@ThinkPad.nowhere.local Reply-To: Martin Dieringer To: Nate Williams Cc: Stephen McKay , freebsd-java@FreeBSD.ORG Subject: Re: strange java calculation errors In-Reply-To: <199907091530.JAA05956@mt.sri.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-java@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org On Fri, 9 Jul 1999, Nate Williams wrote: > > >I use the latest jdk1.1.8_ELF.V99-6-3.tar.gz with applied net-patch. > > >On a few-weeks-old 3.2-STABLE. > > >I have strange arithmetic errors. I sometimes get NaN-s > > >and very big numbers (...E306) which don't appear on any other machine/os > > >and don't appear with the linux-jdk1.2 pre-v2. > > > > We are getting occasional failures in the GregorianCalendar routines. > > For some inexplicable reason it is full of floating point calculations. > > Every so often, one of these calculations is wildly incorrect, and we > > get an ArrayIndexOutOfBoundsException (when looking up the month in > > an array). We have a little bit of trace showing one of the statements > > returning 0 or 9223372036854775807 sometimes (instead of an expected > > result of a few thousand). > > As always, unless we can reproduce this bug, it's almost impossible to > track down. If you can provide us a test case, there is a very good > chance we can fix this. Ok, I set up a sample program. I think it needs to be an awt-application. I don't get any errors without setVisible(), but with a visible frame I get errors every few seconds. It has to be a Thread, too, I think. Probably you know how to track this down further. Martin //BugTest.java ---------------------------------------------- import java.awt.*; import java.util.Random; public class BugTest extends Frame implements Runnable { Random random = new Random(); double weight; double denom; double meatEnergy; double weightgain; public BugTest(){ setSize(100,100); setVisible(true); } public void run(){ while (true){ try{ calc(); } catch (ArithmeticException a) { System.err.println("weight: "+ weight + "\ndenom: "+ denom); a.printStackTrace(); } } } void calc() throws ArithmeticException { weight = random.nextDouble()*10.; meatEnergy= 0.029994563969828213; denom = (.0836 * Math.pow(weight, 1.37)); weightgain = .2849372 * meatEnergy * weight / denom; if (weightgain > 1000.) throw new ArithmeticException("weightgain "+weightgain); } public static void main(String args[]){ BugTest bug = new BugTest(); Thread bugThread = new Thread(bug); bugThread.setPriority(Thread.MIN_PRIORITY); bugThread.start(); } } //------------------------------------------------------ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-java" in the body of the message