[R] how to keep very small or large number?

Tuszynski, Jaroslaw W. JAROSLAW.W.TUSZYNSKI at saic.com
Thu Sep 22 19:41:18 CEST 2005

 R can hold very small numbers. It is the round-off error during addition
(and other basic operations) that causes the problem. For example:
> x=1e-300
> x
[1] 1e-300
> (x+1)-1
[1] 0

If you need a code that can be immune to round-off problems - you need to
write it yourself (please correct me if I am wrong). At some point I needed
'sum' and 'cumsum' that would not have that problem and I end up writing my
own versions of those functions. See examples of 'sum.exact' and
'cumsum.exact' in 'caTools' package. 

Jarek Tuszynski

-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch] 
Sent: Thursday, September 22, 2005 12:53 PM
To: r-help at stat.math.ethz.ch
Subject: [R] how to keep very small or large number?

When I was computing some joint probabilities, I found that R reported most
of the results to to -Inf and thus didn't record the value. I guess it is
b/c the joint log(probability) can be extremely small. Is there a way in R
to keep the values even if they are small?

R-help at stat.math.ethz.ch mailing list
PLEASE do read the posting guide!

More information about the R-help mailing list