浮点减法会增加奇怪的尾随值

时间:2017-02-05 19:06:07

标签: python floating-point subtraction

我确定那里有答案,但我找不到答案。

为什么python会将0.000000000000000009添加到此浮点减法中?

Python 2.7.12 (default, Oct 10 2016, 21:41:23)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.38)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 1.01-1
0.010000000000000009
>>> 1.01-1.0
0.010000000000000009
>>> (1 + 0.01)-1
0.010000000000000009
>>>

0 个答案:

没有答案