Today I Learnt (TIL)
To always use the java.math.BigDecimal constructor which accepts String argument.
Why?
The constructor accepting double might behave ‘unexpectedly’ as it retains the floating point precision of the double input.
Resources
- The Curious Schemer - The Evil BigDecimal Constructor
- This StackOverflow entry
- Video of a Java Puzzler by Josh Bloch on Google I/O 2011