BigDecimal in Java
- Jonathan
- May 6, 2019
- 1 min read
If you are dealing with money, or precision is a must, use BigDecimal. Otherwise Doubles tend to be good enough.
The disadvantage of BigDecimal is that it's slower, and it's a bit more difficult to program algorithms that way (due to +, -, * and / not being overloaded).
Example:
Result:
Comentarios