If I have a receipt with the following:
- 4.37
- 4.37
Each item discounted at 10%
4.37 * 10% = .44. rounded from .437
4.37 * 10% = .44 rounded from .437
total discount .88
subtotal is 7.87 rounded from 3.933 + 3.933 = 7.866
7.87 * 5.5% tax = .43 rounded from .43285
- Grand Total is 7.87 + .43 = 8.30
However the physical receipt in my hand shows the discount to be .87.
- D: .87
- S: 7.87
- X: .43
- T: 8.30
How can this be?
I'm trying to write an java/android app that prints a receipt but my numbers do not always match the physical receipts I compare it against. I suspect it has something to do with rounding. How should I be rounding these values? Btw, I'm using the Java BigDecimal.
If I understand the question correctly, I'm guessing you should round after the calculations, not at each step. So the total discount is
$$2\cdot 4.37\cdot 0.1 = 0.874 $$
and rounded to the correct number of decimal places is $0.87$.