[R] Looking for greater floating-point precision

Gabor Grothendieck ggrothendieck at gmail.com
Fri Nov 17 13:21:46 CET 2006


On 11/17/06, Paul Smith <phhs80 at gmail.com> wrote:
> On 11/16/06, Prof Brian Ripley <ripley at stats.ox.ac.uk> wrote:
> > > For my calculations, I am needing to use more floating-point precision
> > > than the default one of R. Is that possible? And, if yes, how?
> >
> > See package gmp (but that will be slow and cumbersome for all but simple
> > calculations).
> >
> > The real issue is that R already uses the maximum precision of the FPU for
> > many common FPUs (but not all).  Since you have forgotten to tell us
> > anything about your environment we don't know if that applies: there may
> > be compiler options you can use to raise the precision.
> >
> > Please do study the posting guide: we are surprisingly good at
> > mind-reading, but prefer to be told exactly what you want to do with R in
> > what environment and why you are 'needing' something.
>
> Thanks, Gabor and Prof. Ripley. After some research, I conclude that
> the problem occurring to me cannot be removed for any finite
> floating-point precision. (I do need infinite floating-point
> precision.) The problematic operation is the successive multiplication
> of reals between 0 and 1; after a certain number of multiplications,
> significant rounding errors occur.
>
> I did read the posting guide, but I could not anticipate the relevance
> of indicating the environment that I am using: Fedora Core 6 (Linux)
> running on a Pentium Dual Core and R 2.4.0.
>

Note that Ryacas can do exact rational arithmetic too in case the reason
your reals require infinite precision is just that they are attempting to
represent rationals.

> yacas("1/2 * 3/4 * 7/8")
expression(21/64)



More information about the R-help mailing list