Here are some different attempts to print out the contents of a double value:
import java.math.*;
public class FloatShow {
public static void main(String ... args) {
System.out.println(1.2);
System.out.println(new Double(1.2).toString());
System.out.println(new BigDecimal(1.2).toString());
}
}
This prints out
1.2
1.2
1.1999999999999999555910790149937383830547332763671875
The println method given a double boxes it and calls toString, similarly the Double uses toString, which is doing some rounding for you. The BigDecimal uses the raw value to construct an instance, and presents it without cleanup. So your assumptions about precision were invalid.
Floating point and fixed decimal are two different concepts. Here is the definition of floating point arithmetic in wikipedia:
In computing, floating-point arithmetic (FP) is arithmetic using formulaic representation of real numbers as an approximation to support a trade-off between range and precision. For this reason, floating-point computation is often found in systems which include very small and very large real numbers, which require fast processing times.
But fixed decimal (like BigDecimal) is different, it stores the individual digits. BigDecimal is slower to use, but it doesn't make the kind of range-precision trade-off that floating point does.
Floating point is good for graphics and engineering applications where the calculation is the bottleneck, the inputs are not entirely precise (but precise within a known error range) and it can be calculated that the speed is worth the trade-off. For a lot of business applications the performance difference is not an issue because something else is always the bottleneck, values are known exactly, and accuracy is not negotiable.