标签: python floating-point precision
在python中:
>>> x = [0.287, 0.059, 0.118, 0.001, 0.001, 0.024, 0.307, 0.001, 0.201, 0.001] >>> print sum(x) 1.0
但是:
>>> print sum(x) == 1.0 False
为什么浮点错误会导致这种情况?有人可以解释吗?