简体   繁体   中英

The Largest factorial number in R

If I run the factorial(1:200) , the largest value is 7.257416e+306 , any value above that is "Inf" .

  1. Does this means the largest value inside R programming is 7.257416e+306 . We can not calculate the value above factorial(170) ?
  2. But when I run the code ".Machine$double.xmax", the biggest value is 1.797693e+308 .

So, I am a bit confused, which one is the biggest value in R?

The largest number in base R has nothing to do with the factorial function. The likelihood that the largest number is going to coincide with a factorial is very small. The largest representable number differs depending on your computer. You can see it by running. .Machine$double.xmax . Everything above that is Inf .

You see 171*factorial(170) is simply larger than your machine's .Machine$double.xmax even though factorial(170) is smaller.

If you want larger numbers in R consider the discussion in this question

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM