It seems to me that you need to read-up on floating-point arithmetic. The types "float" and "double" are floating-point.
Floating-point types can store values with a very wide range of magnitude, but they cannot store all values precisely. In your case, you are hoping for twenty decimal digits of precision, but even a "double" can only store about 14 (something like that, anyway).
When performing calculations with floating-point, errors accumulate, due to the imprecision of the values. This means that you can rarely trust the last digit of the value. For complex calculations, further digits may become untrustworthy, too.
Typically, when printing-out a "float" or "double",
you should use NumberFormat, to format the value to a number of decimal digits that suits your application and is within the accuracy of the calculations performed.
Note that issues of floating-point precision are common to most languages and also applications like spreadsheets. It's not specific to
Java. In my opinion, this is far from an "advanced" topic, by the way; it's something that anyone doing calculations with a computer should know.
[ February 24, 2005: Message edited by: Peter Chase ]