Precision Issue
Casey Stein
cstein at giftcertificates.com
Fri Aug 3 12:52:08 EDT 2001
So I'm going through the Python tutorial and I get to the part on
lists, queues and such and the following happens:
>>> a = [66.6, 333, 333, 1, 1234.5]
>>> print a.count(333), a.count(66.6), a.count('x')
2 1 0
>>> a.insert(2, -1)
>>> a.append(333)
>>> a
[66.599999999999994, 333, -1, 333, 1, 1234.5, 333]
>>> print a
[66.599999999999994, 333, -1, 333, 1, 1234.5, 333]
>>> print a.count(66.6)
1
>>>
Why is it converting my 66.6 to 66.599999999999994?
More information about the Python-list
mailing list