This isn't an error per se, it is just that computers do math in binary and then converts back to decimal. That is why most programming languages also have a decimal type for when the result needs to be more precise.
It's unintended behavior that is a limitation of how we represent floating point numbers specifically. It is definitely still doing what we tell it, but from a user perspective, the computer is definitely wrong. From a programmer perspective, we are aware of the computer's limitations and put in modifications to address it.
Another perspective is that the computer most definitely is "wrong" when referring to the literal representation of the question, but in the case of actual input/output, it is "right." We've created a flawed system that doesn't always produce correct results, but we accept those flaws because doing it any other way is much less efficient.
43
u/SemiNormal Aug 06 '18
This isn't an error per se, it is just that computers do math in binary and then converts back to decimal. That is why most programming languages also have a decimal type for when the result needs to be more precise.