# Different results from adding tax to each item's price versus adding it to the total

The math problem I encountered which is a bit of an anomaly is this :

Suppose you are producing an invoice for a customer, and all items for that invoice are stored in a list (without taxes pre-calculated):

Hamburger - 5.24
Pizza Slice - 3.75
Cheese - 1.12

And assuming the tax percent is 13%.

Everything seems to be ok, if you use only one method (aka, sum total + tax, or each item + items for tax), but they differ in end value since you must round.

Explained:

On an invoice/receipt, you can not put a remainder -- you must always round as the person paying can not pay in fractions of a cent, so given the above example in a summary list, would look something like :

Hamburger - 5.24 + Tax: 0.68
Pizza Slice - 3.75 + Tax: 0.49
Cheese - 1.12 + Tax: 0.15

Everything seems ok, if you sum them up, looks perfect with a total of: 11.43

However if you wish to produce a summary (SUM total of items + tax), you end up with a different result -- which is also correct ?

Hamburger - 5.24
Pizza Slice - 3.75
Cheese - 1.12

Tax: 1.31

If you add the rounded taxes from the itemized list, you get 1.32. A difference of a penny.

So the question is how can one produce both a summary and an itemized list that accurately reflects the correct taxes, and which one is actually correct ?

• Which method is correct is not a mathematical question but rather one of tax legislation. – Hagen von Eitzen Apr 1 '14 at 12:41
• I'm not sure that statement is true, as math really only has one correct answer per equation. 13% of a sum total vs 13% of each of it's parts then summed, should not vary, but it does, so only one of those is actually true. It is similar to (100/3)*3 <> 100 . – user139393 Apr 1 '14 at 12:46
• Mathematically, you do not round at all. The answer is $11.4243$ either way. Tax legislation tells you whether you round the total, or the single items. That different rounding strategies can lead to different results should not come as a surprise. – Daniel Fischer Apr 1 '14 at 12:53
• I've had this question in my mind for a long time. This does not apply only in taxes. It could be the result of a poll. (30 persons voted, 10 for each option). so every option gets 33,33%. but the sum should be 100%. This gets more "erroneous" if you have more possible options. The question is not "why does it happen?". The question is "how to deal with this?", assuming we want to use decimal representation. – Thanos Darkadakis Apr 1 '14 at 12:59