对于真正简单而愚蠢的问题,我表示歉意;但是,为什么这两种情况显示的精度有差异?Python数组中的浮点精度
1)
>> test = numpy.array([0.22])
>> test2 = test[0] * 2
>> test2
0.44
2)
>> test = numpy.array([0.24])
>> test2 = test[0] * 2
>> test2
0.47999999999999998
我使用64位Linux python2.6.6。 非常感谢您的帮助。
这也持似乎憋了列表蟒蛇
>>> t = [0.22]
>>> t
[0.22]
>>> t = [0.24]
>>> t
[0.23999999999999999]
那怎么彩车工作 - “以神秘的方式”)。很多问题都是我无法解决的问题。 – delnan 2011-03-01 21:07:38
我不会称之为任何东西的重复,因为答案是非常具体的Python(加上它是我的答案:))。 – Zooba 2011-03-01 21:45:50