[Pythonmac-SIG] Numeric issue (not Mac specififc?)
Stefan Witzgall
stefan.witzgall@online.de
Tue, 10 Apr 2001 07:03:11 +0200
Playing around I found the following:
>>> 6666666666666.2+9
6666666666675.2002
>>> 66.2+9
75.200000000000003
>>> 66.2+9.0
75.200000000000003
>>> 0.2+9.0
9.1999999999999993
>>>
Is this lack of accuracy documented, perhaps in the description of the
types Python use? Is there a possibility to get a predictable accuracy or
behavior, or is there a module out anywhere to do mathematical operations
in a "better" way?
I didn't have any problems with this yet, but this would make it necessary
to use intervals, and epsilons and deltas, to test if reals are "equal".
Stefan
<Stefan.Witzgall@online.de>