The problem is that f1 cannot be represented in a float as 12.84, so
Java uses the closest approximation. Then when the float is converted to a double, the extra decimal places result from the slight difference between 12.84 and f1.
If you want to see this, try your code again with "double f1=12.84;".
Another way to handle this is to just show 2 decimal places. You can use the NumberFormat class or, in Java 5, printf() with %.2f. Eiher way, Java will round your output to 2 decimal places.