[R] Extending the accuracy of exp(1) in R

Duncan Murdoch murdoch.duncan at gmail.com
Tue Nov 9 14:29:07 CET 2010

On 09/11/2010 8:21 AM, Shant Ch wrote:
> Hi,
> I want to use a more accurate value of exp(1).  The value given by R is
> 2.718282. I want a value which has more than 15 decimal places. Can anyone let
> me know how can I increase the accuracy level.

The value in R is accurate to approximately 15 decimal places; it only 
prints to 6 by default.

> Actually there are some large multipliers of exp(1) in my whole expression, and
> I want a more accurate result at the last step of my program, and for that I
> need to use highly accurate value of exp(1).

It's really unlikely that this would help.  Most computations in R are 
done in double precision, so having one constant at higher precision 
won't affect much.  You could replace all computation with higher 
precision by using the gmp package, but it's not a painless procedure, 
and it would cut you off from code in most packages.

I think you probably want to re-think the computation you're doing to 
figure out how to do it with 15 digit arithmetic.  Have you looked at 
the expm1() and related functions?

Duncan Murdoch

> Can anyone help me out? Thanks.
> Shant
> 	[[alternative HTML version deleted]]
> ______________________________________________
> 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