Tim Peters <tim.pet...@gmail.com> added the comment:

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 ;-)

----------
nosy: +tim_one

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue7704>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to