Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 9 Jul 1999 16:04:32 -0600
From:      Nate Williams <nate@mt.sri.com>
To:        Martin Dieringer <dieringe@zedat.fu-berlin.de>
Cc:        Nate Williams <nate@mt.sri.com>, Stephen McKay <syssgm@detir.qld.gov.au>, freebsd-java@FreeBSD.ORG
Subject:   Re: strange java calculation errors 
Message-ID:  <199907092204.QAA09955@mt.sri.com>
In-Reply-To: <Pine.BSF.4.10.9907092353330.44163-100000@ThinkPad.nowhere.local>
References:  <199907091530.JAA05956@mt.sri.com> <Pine.BSF.4.10.9907092353330.44163-100000@ThinkPad.nowhere.local>

next in thread | previous in thread | raw e-mail | index | archive | help
> > > >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.

This is great, thanks Martin!  I'm able to reproduce this error running
your program on my box.

Unfortunately, I won't be able to look at it anytime soon as I'm going
on vacation next week, but maybe when I get back!

Again, thanks for simple test.  This makes our job *much* easier.



Nate

> 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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199907092204.QAA09955>