New submission from Constantino Antunes:

I was using python as my calculator when I got a result which had to be rounded 
to be the value I expected. So I made some tests with a simple case.
Given that 0.38 - 0.20 = 0.18, then 1000.38 - 1000.20 should be also 0.18.

Here is this calculation done on three different systems:

Python 2.7.5 (default, Mar  9 2014, 22:15:05) 
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 0.38 - 0.20
0.18
>>> test = lambda x: (x+0.38) - (x+0.20)
>>> test(0)
0.18
>>> test(1000)
0.17999999999994998
>>> test(1000000)
0.18000000005122274
>>> test(1000000000)
0.1799999475479126
>>> test(1000000000000)
0.1800537109375
>>> test(1000000000000000)
0.125

---

Python 2.7.3 (default, Mar 13 2014, 11:03:55) 
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 0.38 - 0.20
0.18
>>> test = lambda x: (x+0.38) - (x+0.20)
>>> test(0)
0.18
>>> test(1000)
0.17999999999994998
>>> test(1000000000000000)
0.125

---

Python 2.4.3 (#1, Oct 23 2012, 22:02:41) 
[GCC 4.1.2 20080704 (Red Hat 4.1.2-54)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 0.38 - 0.20
0.17999999999999999
>>> test = lambda x: (x+0.38) - (x+0.20)
>>> test(0)
0.17999999999999999
>>> test(1000)
0.17999999999994998
>>> test(1000000000000000)
0.125

----------
messages: 226270
nosy: Constantino.Antunes
priority: normal
severity: normal
status: open
title: wrong subtraction result
versions: Python 2.7

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

Reply via email to