我为这个非常简单而愚蠢的问题道歉; 但是,为什么这两种情况的精确度有差异?
1)
>> test = numpy.array([0.22])
>> test2 = test[0] * 2
>> test2
0.44
Run Code Online (Sandbox Code Playgroud)
2)
>> test = numpy.array([0.24])
>> test2 = test[0] * 2
>> test2
0.47999999999999998
Run Code Online (Sandbox Code Playgroud)
我在64位linux上使用python2.6.6.预先感谢您的帮助.
这似乎也适用于python中的列表
>>> t = [0.22]
>>> t
[0.22]
>>> t = [0.24]
>>> t
[0.23999999999999999]
Run Code Online (Sandbox Code Playgroud)