[R] numeric not equal its value

Rui Barradas ruipbarradas at sapo.pt
Tue May 21 14:50:58 CEST 2013


Hello,

That's FAQ 7.31.
Note that the increment, 0.05, is not a power of 2 so the third value of 
the sequence is not exactly equal to 0.15.

Hope this helps,

Rui Barradas

Em 20-05-2013 13:36, Jannis escreveu:
> Dear R users,
>
>
>
> I ran into the strange situation where a number does not seem to equal
> its value. Try this:
>
>
>
> a <- seq(0.05,0.7,0.05)[3]
>
> b <- 0.15
>
> a == b
>
>
> Should this not be TRUE? a-b yields a very small number (and not 0) so
> this most probably is a numerical error, but why does seq create such
> numbers?
>
>
> Thanks a lot
> Jannis
>
> ______________________________________________
> R-help at 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.



More information about the R-help mailing list