Take the following example:
>>> from decimal import Decimal
>>> nrml_price = Decimal('0.59')
>>> discounted = nrml_price / 3 # Taking 2/3 off the price with a coupon
Decimal('0.1966666666666666666666666667') # Customers don't have fractions of a penny
>>> (nrml_price / 3).quantize(D('0.00')) # So I quantize to get 2 decimal places
Decimal('0.20') # Ca fait combien? Cest vingt cents.
The problem is that I've now technically charged the customer for more than the expected price, albeit by less than 3/10 of a cent, but nonetheless it is technically incorrect.
How do I overcome a problem like this? Do I ignore it as a fact of life, or is there an accepted way to do this sort of thing (e.g. always charge the customer the nearest penny down)?