[Rd] BUG in " == " ? (PR#9065)

Peter Dalgaard p.dalgaard at biostat.ku.dk
Fri Jul 7 11:59:04 CEST 2006


eric.durand at imag.fr writes:

> Hello,
> here is the version of R that I use :
> 
> > version
>                _
> platform       i486-pc-linux-gnu
> arch           i486
> os             linux-gnu
> system         i486, linux-gnu
> status
> major          2
> minor          3.1
> year           2006
> month          06
> day            01
> svn rev        38247
> language       R
> version.string Version 2.3.1 (2006-06-01)
> 
> And here is one of the sequences of isntruction that returns an abberation : 
> 
> > x<-seq(0,1,by=0.01)
> > x[71]
> [1] 0.7
> > which(x == 0.7)
> numeric(0)
> > x[71] == 0.7
> [1] FALSE
> 
> Or another version of (maybe) the same bug : 
> 
> > x <- 70
> > x == 70
> [1] TRUE
> > x <- x*0
> > x <- 70
> > x == 70
> [1] TRUE
> > x<-x*0.01
> > x
> [1] 0.7
> > x == 0.7
> [1] FALSE
> 
> It seems completely strange ... any help would be greatly appreciated :)

FAQ 7.31

http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-doesn_0027t-R-think-these-numbers-are-equal_003f
-- 
   O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)                  FAX: (+45) 35327907



More information about the R-devel mailing list