This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author tim.peters
Recipients DhaReaL, mark.dickinson, tim.peters
Date 2010-01-14.22:37:40
SpamBayes Score 1.3157538e-06
Marked as misclassified No
Message-id <1263508662.41.0.908399474474.issue7704@psf.upfronthosting.co.za>
In-reply-to
Content
You can use the comparison, provided you understand what it does, and that it does NOT do what you hoped it would do.  Here:

>>> 1.6 - 1.0
0.60000000000000009

That shows quite clearly that subtracting 1 from the binary approximation to 1.6 does not leave exactly 0.6.  If you need that to happen, use the decimal module (which, in return for being slower, emulates decimal floating-point arithmetic).

Your other case (8.6-8.0) does NOT equal (decimal) 0.6 exactly either, but fools you into thinking it's working the way you hope it works because the result is a little /less/ than 0.6:

>>> 8.6 - 8.0
0.59999999999999964

Do read the tutorial appendix Mark invited you to read.  If you don't, you're going to remain hopelessly confused ;-)
History
Date User Action Args
2010-01-14 22:37:42tim.peterssetrecipients: + tim.peters, mark.dickinson, DhaReaL
2010-01-14 22:37:42tim.peterssetmessageid: <1263508662.41.0.908399474474.issue7704@psf.upfronthosting.co.za>
2010-01-14 22:37:41tim.peterslinkissue7704 messages
2010-01-14 22:37:40tim.peterscreate