[R] Can R change my input at higher precision

R. Michael Weylandt michael.weylandt at gmail.com
Sat Nov 17 15:16:34 CET 2012


See http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-doesn_0027t-R-think-these-numbers-are-equal_003f

Michael

On Sat, Nov 17, 2012 at 12:56 PM, Gonçalo Ferraz <gferraz29 at gmail.com> wrote:
> I just found a problem that may be causing an error in a computation with very small numbers:
>
> I tell R that
>
> thetaP <- 5.531003
>
> and when I ask R to show me thetaP with more precision, it gives me
>
> thetaP
> [1] 5.531003000000000114
>
> and even more surprising, if I write
>
> thetaP <- 5.531003000000000000
>
> again, I get:
>
> thetaP
> [1] 5.531003000000000114
>
> Is this supposed to happen?
>
> Is there a way to avoid it?
>
> Thank you for any advice.
>
> Gonçalo
>
> ______________________________________________
> 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