thank you to all who answered.

> 0+0.05+
+ 0.05+0.05+0.05+0.05+0.05+0.05+
+ 0.05+0.05+0.05+0.05+0.05+0.05+
+ 0.05+0.05+0.05+0.05+0.05+0.05 - 0.95
[1] 3.330669e-16

> seq(0,1,0.05)[20] - 0.95
[1] 1.110223e-16

> 0+19*0.05 - 0.95
[1] 1.110223e-16

so this is the way seq calculates. I would have guessed
that addition was more accurate than multiplication,
but that is not the case.

this one however bothers me:
> 19/20-0.95
[1] 0


I noticed this problem when I tried to extract rows of a matrix
according to whether values of some vector where in the set
(0,0.05,...,0.95,1), with something like x%in%seq(0,1,0.05)
Now I understand that I should not use this construction
unless x is of type integer. Would you agree?

Eric Elguero

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to