When entering 1e9999999999999999999999999999999 into R, R hangs and will not respond - requiring it to be terminated.

It seems to happen across 3 different computers, OSes (Windows 7 and Ubuntu). It happens in RStudio, RGui and RScript.

Here's some code to generate the number more easily:

boom <- paste(c("1e", rep(9, 31)), collapse="")
eval(parse(text=boom))

Now clearly this isn't a practical problem. I have no need to use numbers of this magnitude. It's just a question of curiosity.

Curiously, if you try 1e9999999999999999999999999999998 or 1e10000000000000000000000000000000 (add or subtract one from the power), you get Inf and 0 respectively. This number is clearly some kind of boundary, but between what and why here?

I considered that it might be:

  • A floating point problem, but I think they max out at 1.7977e308, long before the number in question.
  • An issue with 32-bit integers, but 2^32 is 4294967296, much smaller than the number in question.
  • Really weird. This is my dominant theory.

EDIT: As of 2015-09-15 at the latest, this no longer causes R to hang. They must have patched it.

r
Edit
Report