Skip to content

Handling very large integers with factorial and combinat (nCm)

2 messages · Marco Chiarandini, Brian Ripley

#
Dear list,

perhpas this question is more suitable for R-dev but since I am not
really a developer I post it here first.

Apparently the following lines do not create any problem in R:

library(combinat)
r <- 20; b <- 2;
sum( sapply(0:r,function(x) nCm(r,x)^(2*b)) ) > 2^64

while in C I obtain an overflow of data even using unsigned long long
and with long double I incurr in precision problems.

Where can I find information about how R (or the combinat package)
handles very large integer numbers?


Thank you for consideration,


Marco
#
On Mon, 4 Apr 2005, Marco Chiarandini wrote:

            
In this case, as doubles.  R numeric variables are doubles, and 'r' and 
'b' are numeric, not integer.  However,
gives the same result (and internally nCm computes in doubles: Note that 
factorials are computed via lgamma).