[5390] in java-interest
Re: Numbers
daemon@ATHENA.MIT.EDU (Jill Shermer)
Wed Feb 7 13:13:20 1996
Date: Wed, 7 Feb 1996 08:37:35 -0800
From: jshermer@BASISinc.com (Jill Shermer)
To: pat@icon-stl.net
Cc: java-interest@java.sun.com
> Subject: Re: Numbers
> MIME-Version: 1.0
> X-Info: To unsubscribe, send 'unsubscribe' to java-interest-request@java.sun.com
>
>
> On Tue, 6 Feb 1996, Jill Shermer wrote:
>
> > 2. How do you avoid loss of precision with doubles?
> >
> > For example, if a = 300000.33,
> > b = 2,
> > c = a*b,
> >
> > how do you make sure c = 600000.66, not 600001?
> > Is this avoidable?
>
> It should be more clear if you declare the types of your variables.
> Unless you perform an explicit cast, the type of c will have to be double
> and the value will be 600000.66
>
I have explicitly declared a,b, and c to be doubles in my Java code, and
I still lose precision.
-Jill
-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com