precision - Why does exp(log(6)) == exp(log(3)) * 2 return FALSE in R? -


this question has answer here:

in r, why false y > 2?

y <- c(1, 2, 3, 4, 5) x <- 2*y exp(log(x)) == exp(log(y)) * 2 [1]  true  true false false false 

numeric precision. try calculating difference:

exp(log(x)) - exp(log(y)) * 2 

you use like:

all.equal( exp(log(x)) , exp(log(y)) * 2 ) 

Comments