Decimal arithmetic, with example code

James J. Besemer jb at cascade-sys.com
Tue Oct 1 18:43:13 EDT 2002


Tim Peters wrote:

>No single rounding discipline is
>suitable for all commercial applications, 
>
Ain't it the Truth!!

Businesses in the US are required to file quarterly reports about periodic tax payments made during the quarter.  Taxes, e.g. on FICA and Medicare, are computed as a percentage of each employee's wages and deducted from the employee's paycheck each pay period.  On the quarterly report, the actual liability is computed, based as a percentage of total payroll for the period.   

These two computations (sum of percentages and percentage of sums) do not always produce the same amount.  And yet the amounts on the return have to match to the exact penny -- no rounding off to the nearest dollar (like on personal returns).  Consequently, the form includes an explicit entry for "round off error," to correct for minor differences in computed liability vs. actual payments.

--jb

-- 
James J. Besemer		503-280-0838 voice
2727 NE Skidmore St.		503-280-0375 fax
Portland, Oregon 97211-6557	mailto:jb at cascade-sys.com
				http://cascade-sys.com	








More information about the Python-list mailing list