Bug Report on float number calculation in IDLE
Grey <[email protected]> Sat, 19 Dec 2015 18:20:06 +0800 (GMT+08:00)
| Newsgroups | gmane.comp.python.idle |
|---|---|
| Message-ID | <[email protected]> |
Hi there:
I have found a strange issue on float number calculation in IDEL of Python 2.7X。
1,When I tried to calculate the sum of a bunch of float numbers in IDLE of Python 2.7.6 I found that the result was not accurate(well, I have knew that it is up to the storage format of data by searching the information on Internet). However, when I try to use print statement to print the result it gave me the right answer. That means the calculation in IDLE may be not the same with that in print statement for a script.The records can be found in attachment named P1_2.7.6.JPG and T1_2.7.6.
2,I tried to update my Python to 2.7.11, the result is same as that in Python 2.7.6. The records can be found in attachment name P2_XXX and T2_XXX。
3, Once again, I tried Python 3.5.1. The result is the same, but both of them was not accurate. I know the reason may be the same as I wrote in description 1. The good news is that the result keeps the same with each other.
In summary of all above, I think that the calculation of float numbers in IDLE of Python 2.7X is not the same with the result of that in Print statement or that in a script.
Thanks and regards!
Grey from China, a beginner of Python.
_______________________________________________
IDLE-dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/idle-dev
P1_2.7.6.JPG
(image/jpeg, 36.9 KB) - not displayed
P2_2.7.11.JPG
(image/jpeg, 32.9 KB) - not displayed
P3_3.5.1.JPG
(image/jpeg, 31 KB) - not displayed
T1_2.7.6.txt
(text/plain, 306 B)
Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information. >>> 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 0.8999999999999999 >>> print(0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1) 0.9 >>>
T2_2.7.11.txt
(text/plain, 317 B)
Python 2.7.11 (v2.7.11:6d1b6a68f775, Dec 5 2015, 20:32:19) [MSC v.1500 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information. >>> 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 0.8999999999999999 >>> print(0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1) 0.9 >>>
T3_3.5.1.txt
(text/plain, 306 B)
Python 3.5.1 (v3.5.137a07cee5969, Dec 6 2015, 013848) [MSC v.1900 32 bit (Intel)] on win32 Type copyright, credits or license() for more information. 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 0.8999999999999999 print(0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1) 0.8999999999999999