This is a consequence of the way floating-point numbers are stored in computers (per IEEE 754 standards). If the decimal portion cannot be expressed as a sum of reciprocal powers of 2 within a particular "window," then the number loses precision.
If you want precision, then
you should use the BigDecimal class in java.math. But be sure to use the
String constructor, or you'll get similar errors. Compare the String and double constructor descriptions in the API...
http://java.sun.com/j2se/1.4.2/docs/api/java/math/BigDecimal.html For details on IEEE 754, follow the links here...
http://www.public.iastate.edu/~sarita/ieee754/homepage.html [ October 04, 2004: Message edited by: marc weber ]