Displaying 1 result from an estimated 1 matches for "tp25686630p25687626".
2009 Sep 30
5
Rounding error in seq(...)
Hi,
Today I was flabbergasted to see something that looks like a rounding
error in the very basic seq function in R.
> a = seq(0.1,0.9,by=0.1)
> a
[1] 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9
> a[1] == 0.1
[1] TRUE
> a[2] == 0.2
[1] TRUE
> a[3] == 0.3
[1] FALSE
It turns out that the alternative
> a = (1:9)/10
works just fine. Are there any good guides out there on how to deal