[R] numeric equality

Sarah Goslee sarah.goslee at gmail.com
Wed Mar 18 17:53:28 CET 2009


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 <YuC at ccf.org> 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
>
>> 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 version is Windows XP R version 2.8.1 (2008-12-22).
>
>
>
> Thanks very much.
>
>
>
>
>
> Changhong
>
>

-- 
Sarah Goslee
http://www.functionaldiversity.org




More information about the R-help mailing list