We know that using double for currency is error-prone and not recommended. However, I\'m yet to see a realistic example, where BigDecimal
double
BigDecimal
When you round double price = 0.615 to two decimal places, you get 0.61 (rounded down) but probably expected 0.62 (rounded up, because of the 5).
double price = 0.615
This is because double 0.615 is actually 0.6149999999999999911182158029987476766109466552734375.