[Pythonmac-SIG] Numeric issue (not Mac specififc?)
Stefan Witzgall
stefan.witzgall@online.de
Tue, 10 Apr 2001 11:58:34 +0200
John,
thank you for this explanation. This behavior is so obvios, that it
couldn't have been a secret for the people working longer with Python than
I.
>And you are correct: one should not compare computed binary floating point
>numbers to zero, or to other constants, or to each other...one should
>instead determine whether one number is close enough to another number.
>"Comparing" includes the exit test of loops.
>
>This only became "obvious" with recent Python versions which don't hide it
>from us (by not rounding off). Before, one had little surprises like:
>
>>>> (0.1 + 0.1 + 0.1) == 0.3
>0
Strange ;-)
>without the hints one gets now that something "strange" is going on.
.. no longer.
>To get more "reasonable" results, use print or other tools...try
>print 6666666666666.2+9
Stefan
<Stefan.Witzgall@online.de>