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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to