So, I am having Mathematica 11.3 and trying to evaluate 2^1,000,000,000.

When I am trying to show the output in its full form to manipulate the digits, Mathematica stops responding.

I am having 32GB of memory so this would not be a problem. Also when I am using Intel's extreme utility to monitor, I find it to always employ 1 kernel out of 8, altho I specifically set it to work with all 8 in the settings and never uses more than 6GB of memory.

  • 2
    $\begingroup$ The number 2^1,000,000,000 is not from real life: eg Planck constant^(-1) is 6.626070150(81)*10^34. $\endgroup$
    – user64494
    Nov 30, 2018 at 12:11
  • 5
    $\begingroup$ @dimachaerus it does not mean you can throw this expansion at any gui and expect it to be responsive. $\endgroup$
    – Kuba
    Nov 30, 2018 at 12:17
  • 2
    $\begingroup$ Also 2^(10^9) has around 3e8 digits. Are you sure 32GB is enough to interactively play with them? $\endgroup$
    – Kuba
    Nov 30, 2018 at 12:21
  • 1
    $\begingroup$ For 8 bits= 1 byte a digit, yes I am certain. Also if it ran out of memory it'd show up on the monitor. I am telling you this program never goes further than 6GB of memory and 1 kernel. $\endgroup$ Nov 30, 2018 at 12:27
  • 3
    $\begingroup$ What exactly do you mean by "manipulate the digits"? $\endgroup$ Nov 30, 2018 at 17:28

2 Answers 2


The Mathematica kernel can handle such numbers. The following returns immediately; note that I suppressed the output with ;.

var = 2^1000000000;

The issue you are perhaps experiencing is that the front-end takes a long time to format and print the number. This is because it is an Integer


and has a large amount of digits


and Mathematica fully prints all digits of integers so this will take the front-end some time. You can return a portion of the digits with IntegerDigits; first 10 below.

IntegerDigits[var, 10, 10]

{1, 7, 8, 7, 1, 0, 9, 3, 7, 6}

You can get better print performance using reals instead of integers. The follow returns the print immediately.

var2 = 2.^1000000000

RealDigits can be used to return digits in this case.

RealDigits[var2, 10, 10]
{{4, 6, 1, 2, 9, 7, 6, 0, 0, 1}, 301029996}

Hope this helps.

  • $\begingroup$ It doesn't help but thanks for the answer. I know all these commands. I am not expecting the output to be any larger than 100MB in size. $\endgroup$ Nov 30, 2018 at 16:02
  • $\begingroup$ The output, printed, is characters. This is true whether the number is stringified or just printed as digits. There are a billion bits, so around 300 million base ten digits. At one byte per ascii character (the minimum) this gives 300MB. That factor of three vs stated expectation might or might not be an issue. $\endgroup$ Nov 30, 2018 at 18:03
  • $\begingroup$ Wrong! It's not 1 byte per character (digit here), tho I claimed this in a previous comment to make sense for some people who are here for downvoting only. 10^300,000,000=2^1,000,000,000 approx. so it's 1,000,000,000/8 bytes is 125MB approximately, you do the math...but you may be right after all the notebook's size is 300MB after saving it with the full answer. $\endgroup$ Nov 30, 2018 at 19:03
  • $\begingroup$ Ascii characters, which are what get used in formatting numbers, occupy a whole number of bytes. And I'm perilously close to awarding this one of my quite rare down votes, and voting to close based on the moving target nature of the question. The number itself is 1.25 MB. I'll put the sizes in my actual response, so that the code for computing them is there. $\endgroup$ Nov 30, 2018 at 19:10
  • 3
    $\begingroup$ @dimachaerus any specific reason for this award? :-) p.s. I was not precise, I didn't mean 300MB is more that 32GB but 3e8 digits is quite a long box which undergoes various processes in a FE. Line breaks, syntax highlighting etc etc. Notebook is more than a simple text editor. $\endgroup$
    – Kuba
    Nov 30, 2018 at 21:28

[Not a full answer but on the long side for comments.]

It is probably a formatting speed issue. Also note that obtaining the digits in base 10 also takes time (it's an O(n log n) algorithm for n the bit length of the number). One way to see that is as below. Notice that getting digits in base 2 is much faster (it's O(n)).

  Timing[IntegerString[2^(10^n), 2];]}, {n, 5, 8}]

(* Out[158]= {{{0., Null}, {0., Null}}, {{0.028, Null}, {0., 
   Null}}, {{0.396, Null}, {0.008, Null}}, {{6.924, Null}, {0.12, 
   Null}}} *)

I would expect that IntegerString might format faster than printing the digits directly, but I'm too scared to try on my memory-limited machine.

As for sizes: the number will occupy an eight of a gig, since it is exactly a billion bits.

ee = 2^(10^9);

(* Out[14]= 125000080 *)

In decimal form, at one byte per character, it will be around 300Mb. This is computed more accurately by any of the means below.

Log[10., 2]*10^9

(* Out[20]= 3.01029995664*10^8 *)

Timing[eeString = IntegerString[ee];]

(* Out[21]= {106.264, Null}

Out[22]= 301030064

Out[23]= 301029996 *)
  • $\begingroup$ I can run this for n=9 with 16 GB of RAM. It takes 98 s on a PC similar in speed to Daniel Lichtblau's. $\endgroup$
    – mikado
    Nov 30, 2018 at 16:36
  • $\begingroup$ That's not what I am asking. To find 2^1,000,000,000 my system takes 0.0468595 s exactly but when I ask Mathematica to show the number in full form: "show all", well it does show it, but then if I want to copy-paste or move the cursor in the evaluated cell, Mathematica halts forever. $\endgroup$ Nov 30, 2018 at 18:13
  • $\begingroup$ What are the platform specifics? Is it possible you have a 32 bit front end? Also have you tried putting the result into InputForm? This might improve the behavior in terms of manuevering inside the cell. $\endgroup$ Nov 30, 2018 at 19:02
  • $\begingroup$ No.. Win10 Enterprise x64, 8700k processor. I'll check the InputForm now, might be the answer... $\endgroup$ Nov 30, 2018 at 19:13
  • $\begingroup$ One possible advantage to the InputForm (sort of implicit in a comment by @Kuba) is that it does not have a BoxData wrapper. This might translate to an easier time moving a cursor into and through the cell. $\endgroup$ Dec 2, 2018 at 13:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.