commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "J.Pietschmann" <>
Subject Re: [math] Math.pow usage was: Re: cvs commit: ...
Date Thu, 19 Jun 2003 19:08:27 GMT
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 :-)


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message