commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mark R. Diggory" <mdigg...@latte.harvard.edu>
Subject Re: [math] Math.pow usage was: Re: cvs commit: ...
Date Thu, 19 Jun 2003 19:16:16 GMT
J.Pietschmann wrote:

> Mark R. Diggory wrote:
>
>> (1) It is very important to also use ((double)x)*x instead of 
>> (double)(x*x), as the loss of precision starts to occur at far 
>> greater values than overflow occurs if one were doing integer arithmetic
>
>
> IIRC Java shares also the C behaviour in that n*n becomes
> negative instead of signalling an overflow. If this is
> embedded in a complicated expression you only notice strange
> results, or not even that. This can be quite hard to debug.
>
> I'm too lazy to run a test to confirm this right now, but I'm
> sure someone else will have done it when I wake up tomorrow :-)
>
> J.Pietschmann
>
Yes I wrote my own little test, it goes negative initially, eventually 
it seems to go to 1 if the magnitude of the overflow gets excessive

-- 
Mark Diggory
Software Developer
Harvard MIT Data Center
http://www.hmdc.harvard.edu



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message