Another often used constructor of BigDecimal is that which takes a
String. This will use the exact number from the String without losing any of the precision. Compare this with double:
Because BigDecimal never rounds automatically or loses precision it is highly preferred in calculations where automatic rounding or losing precision could be disastrous - like financial programs.
That said, BigDecimal does come with a few drawbacks:
- they take up more memory than double
- they are always stored in the heap, not in the stack like double local variables
- you can't use +, -, * etc, but have to call methods like add, subtract and multiply. These all require another BigDecimal as operand so again more memory
The latter may be changed in Java 7; there have been rumours of adding support for +, -, * and / for BigDecimal and BigInteger as has been done with + and String.