I sum like below: 10 + 20.99 = 30.99 but 30.99 + 5.0 = 35.98999999999995 why it doesn't equal to 35.99
Here is my code:
double amount = 0.0;
for (OrderVO orderVO : invoiceCreate.getLstOrderVO()) {
amount += Double.parseDouble(orderVO.getOrderAmount());
}
First loop orderVO.getOrderAmount() = 10 and get amount = 10.0
Second loop orderVO.getOrderAmount() = 20.99 and get amount = 30.99
Third loop orderVO.getOrderAmount() = 5 and get amount = 35.989999999995
How can I get 35.99 (dont round it)?
Aucun commentaire:
Enregistrer un commentaire