Strangeness with basic math

Tim timhoffman at cams.wa.gov.au
Tue Sep 4 03:53:15 EDT 2001


Hi

I have been racking my brains trying to RTFM to explain the following

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)

Regards

Tim



More information about the Python-list mailing list