[5375] in java-interest
Re: Numbers
daemon@ATHENA.MIT.EDU (Pat Niemeyer)
Wed Feb 7 02:44:22 1996
Date: Wed, 7 Feb 1996 00:06:17 -0600 (CST)
From: Pat Niemeyer <pat@icon-stl.net>
To: Jill Shermer <jshermer@BASISinc.com>
cc: java-interest@java.sun.com
In-Reply-To: <9602070227.AA04678@nemesis.BASISinc.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
Pat
-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com