This is one of the joys of floating point arithmetic.  Look at the 7th
element of

  seq(0,1,.1) - 0.6

Also, check the all.equal(x,y,tolerance=epsilon ) function.

John


-----r-devel-bounces@r-project.org wrote: -----


To: r-devel@stat.math.ethz.ch
From: alexandre.courtiol@gmail.com
Sent by: r-devel-bounces@r-project.org
Date: 02/24/2009 08:55AM
cc: R-bugs@r-project.org
Subject: [Rd] invalid comparison in numeric sequence (PR#13551)

Full_Name: alex
Version: 2.8.1
OS: Ubuntu / MacOSX
Submission from: (NULL) (162.38.183.51)


> 0.6==0.6
[1] TRUE
> seq(0,1,0.1)==0.4
 [1] FALSE FALSE FALSE FALSE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE
> seq(0,1,0.1)==0.6
 [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
> seq(0,1,0.1)==0.8
 [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE  TRUE FALSE FALSE


What is wrong with 0.6 ??? (TRUE is missing)
I tried 3 differents computers (2 Ubuntu with R 2.8.1, and one Mac with R
2.8).

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
	[[alternative HTML version deleted]]

