Just for the amusement of the audience. The following is a reusable testscript:
>>> def add_money(amounts): ... pennies = sum([round(int(amount * 100)) for amount in amounts]) ... return float(pennies / 100.0) ... >>> add_money([0.13, 0.02]) == 0.15 0.14999999999999999 >>> add_money([0.13, 0.02]) == 0.15 True >>> assert add_money([0.13, 0.02]) == 0.15 >>> assert add_money([100.01, 99.99]) == 200 >>> assert add_money([0, -13.00, 13.00]) == 0 It's just a matter of perspective... http://fiber-space.de/EasyExtend/doc/consoletest/consoletest.html -- http://mail.python.org/mailman/listinfo/python-list