int64 パッケージ
> library(int64)
> a <- as.int64(1)
> for (i in 1:300) {a <- a*i; print(a)}
[1] 1
[1] 2
[1] 6
[1] 24
[1] 120
[1] 720
[1] 5040
[1] 40320
[1] 362880
[1] 3628800
[1] 39916800
[1] 479001600
[1] 6227020800
[1] 87178291200
[1] 1307674368000
[1] 20922789888000
[1] 355687428096000
[1] 6402373705728000
[1] 121645100408832000
[1] 2432902008176640000
[1] NA オーバーフロー
gmp パッケージ
> library(help=gmp)
> a <- as.bigz(1)
> for (i in 1:21) { a <- a*i; print(a) }
[1] "1"
[1] "2"
[1] "6"
[1] "24"
[1] "120"
[1] "720"
[1] "5040"
[1] "40320"
[1] "362880"
[1] "3628800"
[1] "39916800"
[1] "479001600"
[1] "6227020800"
[1] "87178291200"
[1] "1307674368000"
[1] "20922789888000"
[1] "355687428096000"
[1] "6402373705728000"
[1] "121645100408832000"
[1] "2432902008176640000"
[1] "51090942171709440000"
[1] "1124000727777607680000"
[1] "25852016738884976640000"
単なる numeric
> options(digits=22)
> a <- 1
> for (i in 1:23) { a <- a*i; print(a) }
[1] 1
[1] 2
[1] 6
[1] 24
[1] 120
[1] 720
[1] 5040
[1] 40320
[1] 362880
[1] 3628800
[1] 39916800
[1] 479001600
[1] 6227020800
[1] 87178291200
[1] 1307674368000
[1] 20922789888000
[1] 355687428096000
[1] 6402373705728000
[1] 121645100408832000
[1] 2432902008176640000
[1] 51090942171709440000
[1] 1124000727777607680000
[1] 25852016738884978212864 オーバーフロー!!
※コメント投稿者のブログIDはブログ作成者のみに通知されます