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.


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 ?

  • 1
    $\begingroup$ Which method is correct is not a mathematical question but rather one of tax legislation. $\endgroup$ – Hagen von Eitzen Apr 1 '14 at 12:41
  • $\begingroup$ 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 . $\endgroup$ – user139393 Apr 1 '14 at 12:46
  • 1
    $\begingroup$ 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. $\endgroup$ – Daniel Fischer Apr 1 '14 at 12:53
  • $\begingroup$ 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. $\endgroup$ – Thanos Darkadakis Apr 1 '14 at 12:59
  • $\begingroup$ @ThanosDarkadakis - You are absolutely correct. I am looking more for how to deal with this. Currently using in a real-time scenario, I have been able to minimize the rate of variance by always rounding up, however it still occurs, and it doesn't look good when displaying in an invoice, poll, etc to the user the fractional difference -- especially where money is involved. You would be surprised at how many people complain about a $0.01 difference, and trying to explain this to them..... i dunno whats worse. So I would simply like to find a viable solution to this anomaly. $\endgroup$ – user139393 Apr 1 '14 at 13:08

This is a "solution" I just found. I don't really like it, but it "seems" to solve the problem I'm writing this as an answer because it's difficult to create the table in the comments.

First look just at the 3 first columns. It's the data as you gave them.

We see that (Initial price + rounded tax)=10,11+1,32=11,43, while it should be 11,42.

So we have 0,01 more, which has to be reducted. We are looking for the row with the biggest round error which is the 3rd one. So we reduct the 0,01 from this row.

If the error was 0,02 (=2 units) we would choose 2 rows.

     Initial price   tax(13%)  rounded tax   round error   fixed tax
     5,24            0,6812    0,68          -0,0012       0,68
     3,75            0,4875    0,49           0,0025       0,49
     1,12            0,1456    0,15           0,0044       0,14
Sum  10,11                     1,32


  • The client will not complain about the sum of the taxes, which is easier to be observed than the multiplication amount*tax.


  • It's not mathematically correct to round down the value 0,1456
  • This will not work in the example of 33,33%. This is the case when the row you are searching (with the largest round error) exists twice (or more). In that case maybe we could choose one in random.

What do you think of this approach? Of course I'd be glad to listen as more "solutions" as possible.

  • $\begingroup$ A practical solution to a practical problem. I once spent a full day putting round functions into an Excel spreadsheet so the rounded columns would add. These were columns with five significant figures and (to anybody who thought about it) a probable error of $1-2\%$, but the last digit had to total properly. $\endgroup$ – Ross Millikan Feb 13 '16 at 4:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy