[R] Precision of values > 53 bits

S Ellison S.Ellison at LGCGroup.com
Thu Jan 10 15:56:00 CET 2013


 

> I am working with large numbers and identified that R looses 
> precision for such high numbers.
Yes. R uses standard 32-bit double precision. See ?double in your R help system. And welcome to finite precision arithmetic, which is a very widely known issue in digital comuting ever since it was invented.

> Is there a solution to the problem?
"Yes, lots," said Bilbo, before he remembered not to give his friends away. "No, none at all, not one," he said immediately afterwards. [1]

R cannot easily be recompiled to use higher precision, so in that sense, 'none at all'.

However, you could use something like the Rmpfr package for arbitrary precision arithmetic.
On linux/unix you can use bc (see http://r.789695.n4.nabble.com/Arbitrary-Precision-Numbers-td855931.html)
Or you could do basic things that address the issue: for example, scale, mean-centre or transform the numbers or change your parameterisation so that you do not need high numerical precision on large numbers.


Steve Ellison

[1] JRR Tolkien, ' The Hobbit', Chapter 3 (1937) 

> 
> Thanks a lot
> Stephan
> 
> ______________________________________________
> 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.
> 

*******************************************************************
This email and any attachments are confidential. Any use...{{dropped:8}}




More information about the R-help mailing list