Floating point values ( float and double ) are approximate. You can see rounding errors, and it is actually not possible to accurately represent some values. Think about 1/3 = 0.333333... : In the end, the slots for storing bits run out, and you get "(1/3) * 3 = 0.999999 ..."
In most cases, precise answers are not required to require more than double . If so, check out BigDecimal , which is much slower.
source share