0

I'm sure there is an answer out there but I just can't find it.

Why does python add 0.000000000000000009 to this floating point subtraction?

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
>>>
Realistic
  • 1,038
  • 1
  • 10
  • 20

0 Answers0