**Posted By:**
Anonymous

**Posted On:**
Friday, April 8, 2005 01:26 AM

You probably heard that your computer uses binary numbers. With binary numbers, many decimal numbers cannot be represented exactly. So the internal binary representation is a little bit off, and the internal sum is a little bit more off. When the output string (the decimal number) is computed, there is again a little error. Sometimes you are lucky, and the errors cancel each other; sometimes they don't.

Rules:

(a) When using double, always assume that the numbers will come out a little wrong!!! If this is not acceptable, you MUST USE BigDecimal (in package java.math)!!!!!

(b) If you want to know what really goes on, read any introduction to computer numerics (and prepared for quite some math). After you have understood all in there, you will know whan you can use doubles safely and when not.

Regards

Harald M.