Why is it when I print/display the result of
eval("11.05") + eval("-11")
it comes out as 0.05000000000000071 instead of the expected 0.05. Is there something I am missing?
This has nothing to do with eval. In fact, this is what happens if you type in a console 11.05 - 11:
eval
11.05 - 11
This is a consequence of how programming languages store floating-point numbers; they include a small error. If you want to read more about this, check this out.
1.4m articles
1.4m replys
5 comments
57.0k users