[R] Comparing decimal numbers

mlancee michaellancee at gmail.com
Tue Feb 1 14:49:10 CET 2011


Hi,

I have a seemingly easy question that has been keeping be busy for quite a
while. The problem is the following:

0.1 + 0.1 + 0.1 == 0.3
[1] FALSE

Why is this false? Another example is

0.2 + 0.1 == 0.3
[1] FALSE

or

0.25 + 0.05 == 0.20 + 0.10
[1] FALSE

However, I do get TRUE if I use integers, or for example the following

0.1 + 0.1 == 0.2
[1] TRUE

It is probably something very basic, but I did not manage to find the
answer.

Thanks,
Michael
-- 
View this message in context: http://r.789695.n4.nabble.com/Comparing-decimal-numbers-tp3251437p3251437.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list