Re: [R] numeric equality

2009-03-20 Thread Bernardo Rangel Tura
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

Re: [R] numeric equality

2009-03-18 Thread Yu, Changhong
Thanks very much. -Original Message- From: David M Smith [mailto:da...@revolution-computing.com] Sent: Wednesday, March 18, 2009 12:55 PM To: Yu, Changhong Cc: r-help@r-project.org Subject: Re: [R] numeric equality On Wed, Mar 18, 2009 at 8:58 AM, Yu, Changhong wrote: > Dear all,

Re: [R] numeric equality

2009-03-18 Thread David M Smith
On Wed, Mar 18, 2009 at 8:58 AM, 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 This is expected behaviour. The bottom line is that you

Re: [R] numeric equality

2009-03-18 Thread Sarah Goslee
This is a FAQ: http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-doesn_0027t-R-think-these-numbers-are-equal_003f and also covered nicely in Burns' R Inferno: www.burns-stat.com/pages/Tutor/R_inferno.pdf Sarah On Wed, Mar 18, 2009 at 11:58 AM, Yu, Changhong wrote: > Dear all, > > > > I am totally

[R] numeric equality

2009-03-18 Thread Yu, Changhong
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 > a <- 1 - 0.5 > a == 0.5 [1] TRUE > a <- 1 - 0.6 > a == 0.4 [1] TRUE > a <- 1 - 0.9 > a == 0.1 [1] FALSE My R