numeric equality
On Wed, 2009-03-18 at 11:58 -0400, Yu, Changhong wrote:
Dear all, I am totally confused by the following R output, but don't have a clue for it.
a <- 1 - 0.2
a == 0.8
[1] TRUE
a <- 1 - 0.8
a == 0.2
[1] FALSE
Hi Yu, First of all read FAQ 7.31 (Why doesn't R think these numbers are equal?) Second, in this case, use all.equal a <- 1 - 0.8 a == 0.2 [1] FALSE all.equal(a,0.2) [1] TRUE
Bernardo Rangel Tura, M.D,MPH,Ph.D National Institute of Cardiology Brazil