I came across a strange behavior in Python (2.6.1) dictionaries:
The code I have is:
new_item = {'val': 1.4}
print new_item['val']
print new_item
And the result is:
1.4
{'val': 1.3999999999999999}
Why is this? It happens with some numbers, but not others. For example:
- 0.1 becomes 0.1000...001
- 0.4 becomes 0.4000...002
- 0.7 becomes 0.6999...996
- 1.9 becomes 1.8888...889