Skip to content
Prev 24846 / 398503 Next

%in% not working

Neil Klepeis <nklepeis at uclink4.berkeley.edu> writes:
"Never trust exact equality with floating point operations."

Finite decimal fractions are not finite binary fractions and if you
compute them in two different ways you'll very likely get differences
in the last few bits because of rounding errors.
[1] 1.253
[1] 2.220446e-16

It's not different in principle from the fact that in 3-digit decimal
arithmetic 1/3 * 3 = 0.333 * 3 = 0.999