[R] problem with the precision of numbers

Gabor Grothendieck ggrothendieck at gmail.com
Mon Jan 25 02:04:30 CET 2010


I have added a FAQ to the r-bc home page which should help address
your problems in getting bc to work.

On Sun, Jan 24, 2010 at 5:24 PM, kayj <kjaja27 at yahoo.com> wrote:
>
> Hi All,
>
> I was wondering if R can deal with high precsion numbers, below is an
> example that I tried on using R and Maple where I got different results. I
> was not able to use the r-bc package in R, instead I used the Rmpfr
> package, below are both R and Maple results
>
>
>> library(Rmpfr)
>>
>> s<-mpfr(0,500)
>> j <- mpfr(-1,500)
>>
>> for (i in 0:80){
> + p<-as.numeric(i)
> + c<-choose(80,i)
> + s=s+((j^i)*c*(1-(i+1)*1/200)^200)
> +
> + }
>> s
> 1 'mpfr' number of precision  500   bits
> [1]
> 4.6484825769379918039202329231788093343835337105287241996630873753794810915791302829474613042869191092322033403649086087872119205043462728841279067042348e-6
>
>
> Maple result
>
> 6.656852479*10^(-20)
>
>
> why are the two results different?
>
> I appreciate your help
>
>
>
>
> --
> View this message in context: http://n4.nabble.com/problem-with-the-precision-of-numbers-tp1288905p1288905.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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