Sum of percentages versus percentage of sum

Kenneth Brody kenbrody at bestweb.net
Wed May 31 06:53:00 PDT 2006


The following came up yesterday in a conversation regarding a "why are
these two numbers different" scenario.  Some people may not realize why
the two methods used in the calculation are not the same.

The situation was to calculate X percent of a series of invoices.  (For
example, to calculate a commission.)

One report calculated the sum of all the invoices, and then took X percent.

Another report calculated the sum of X percent of each invoice total.

The results were not the same.

The "problem" is rounding to the nearest penny.  When you take X percent
of each invoice individually, and store the result in a ".2" field, you
are rounding each invoice individually, causing a loss of precision.  When
you calculate the sum of all the invoices first, and then take X percent,
you only round the final result.

(Given infinite precision, the results are, of course, identical.)

Unfortunately, both methods are "correct", depending on your definition of
"X percent of the invoices".

I used sales tax as an example to help clarify the situation.

Consider a place with a 7.5% sales tax.

  The tax on a $1.00 item is 8 cents.  (7.5 cents rounded up to 8.)

    The tax on ten $1.00 items is 75 cents if bought at the same time,
    but 80 cents if bought one at a time.

  The tax on a $0.99 item is 7 cents.  (7.425 cents rounded down to 7.)

    The tax on 10 $0.99 items is 74 cents if bought at the same time,
    but 70 cents if bought one at a time.


Just something to consider if you have a similar situation.  As to which
calculation is "right", talk to your accountant.

-- 
+-------------------------+--------------------+-----------------------------+
| Kenneth J. Brody        | www.hvcomputer.com |                             |
| kenbrody/at\spamcop.net | www.fptech.com     | #include <std_disclaimer.h> |
+-------------------------+--------------------+-----------------------------+
Don't e-mail me at: <mailto:ThisIsASpamTrap at gmail.com>




More information about the Filepro-list mailing list