Strangeness with basic math

Tim Peters tim at zope.com
Tue Sep 4 15:55:03 EDT 2001


[Tim]
> bash-2.03$ python
> Python 2.1 (#1, Jul  3 2001, 10:26:19)
> [GCC 2.95.2 19991024 (release)] on sunos5
> Type "copyright", "credits" or "license" for more information.
> >>> 1923.23 + 17023.34
> 18946.57
> >>> 1923.23 - 17023.34
> -15100.110000000001
> >>> print 1923.23 - 17023.34
> -15100.11
> >>>
>
> Why when I do 1923.23 - 17023.34 am I getting -15100.110000000001
> on NT I get the same thing. Under Python 1.5.2 I get the same and
> result as the print 1923.23 - 17023.34 (ie -15100.11)

Please read

    http://python.sf.net/devel-docs/tut/node14.html

Until then, telling you that 12 changed to 17 since 1.5.2 won't really help
explain it <wink>.





More information about the Python-list mailing list