對於真正簡單而愚蠢的問題,我表示歉意;但是,爲什麼這兩種情況顯示的精度有差異?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