> Why does
>
[quoted text clipped - 3 lines]
>
> tia
Because, according to the JLS and the API specifications, it should give
84.69999999999999
By default, Java converts doubles to strings with enough digits to
recover the exact value of the double, rather than rounding to a
reasonable number of digits. None of 56.8, 27.9, or 84.7 is exactly
representable in double.
If you really want double, but with output rounded to fewer digits, see
java.text.DecimalFormat.
If you need exact handling of bounded length decimal fractions, for
example for simple currency calculations, see java.math.BigDecimal.
Patricia
> Why does
>
[quoted text clipped - 3 lines]
>
> tia
It's the rounding error with doubles ..
you can either use
System.out.println(Math.round(56.8) + Math.round(27.9));
to get 85
or
System.out.println(new BigDecimal(Double.toString(56.8)).add(new
BigDecimal(Double.toString(27.9))).doubleValue());
to get the desired 84.7 :-)
Thank you patricia and martin for the clarification. Will use BigDecimal

Signature
The One
> Why does
>
[quoted text clipped - 3 lines]
>
> tia