Dave Angel wrote:

Easiest answer is to use integers. Scale everything up by a factor of 100, and you won't need floats at all. Just convert when printing (and even then you may get into trouble).

Another answer is to use Decimal class, which CAN represent decimal values exactly.

That only applies to decimal values which can be represented using a fixed number of decimal places. So 1/5 is fine, and is 0.2 exactly, but 1/3 is not, since it would require an infinite number of decimal places.

BTW, if this is supposed to represent US legal tender, you left out the fifty-cent piece as well as the two dollar bill.

http://kowb1290.com/our-two-cents-on-the-two-dollar-bill/



--
Steven

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to