Originally Posted by Philip M
In some cases small errors arise because computers work in binary so they convert your number to the nearest binary equivalent]
This is completely correct, but I feel like it's worth stressing this even more: A computer cannot store every number with exact precision – it simply can't.
And that makes a lot of sense. If you store a floating point number with single precision, you have 32 bit of information. In particular, this number is finite
and since it only uses a finite set of symbols (in fact only two: 0 and 1), the amount of numbers that can be stored is finite. However, even the set of integers is already infinite, let alone the set of real numbers which is "even more infinite" than infinite (we call it uncountable).
This is an important piece of knowledge for any programmer.