You need to be careful in programming when you want to test whether or not two computed
numbers are equal. R will assume that you mean ‘exactly equal’, and what that means
depends upon machine precision. Most numbers are rounded to 53 binary digits accuracy.
Typically therefore, two floating point numbers will not reliably be equal unless they were
computed by the same algorithm, and not always even then. You can see this by squaring
the square root of 2: surely these values are the same?
x <- sqrt(2)
x * x == 2
[1] FALSE
We can see by how much the two values differ by subtraction:
1.1 - 0.2 - 0.9
[1] 1.110223e-16