40

Just asked by my 5 year old kid: what is the biggest number in the computer?

We are not talking about max number for a specific data types, but the biggest number that a computer can represent.

Infinity is not allowed.

UPDATE my kid always wants to print as well, so lets say the computer needs to print this number and the kid to know that its a big number. Of course, in practice we won't print because theres not enough trees.

ivanleoncz
  • 9,070
  • 7
  • 57
  • 49
Yehonatan
  • 1,172
  • 2
  • 11
  • 21
  • 17
    Mine is always one bigger! (Does that answer the question?) – Konrad Rudolph Sep 14 '10 at 11:42
  • 5
    I like how almost none of the answers take into account the question originated from a 5-year-old. – BoltClock Sep 14 '10 at 11:51
  • 7
    Sad the question is closed. It's actually quite interesting. Let's say your hard drive is 1 TB (8'000'000'000'000 bits), and you would print the number that fits on it on paper as hex digits (nobody would do that, but let's assume), that's 2,000,000,000,000 hex digits. Each page would contain 4000 hex digits (40 x 100 digits). That's Now stack the pages on top of each other (let's say each page is 0.004 inches / 0.1 mm thick), then the stack would be as 5 km tall. – Thomas Mueller Sep 14 '10 at 12:01
  • 3
    Voted to reopen. The given reason for closing seemed spurious "not a real question". It clearly is a real question, although it might be off topic... – JeremyP Sep 14 '10 at 12:48
  • @Yehonatan - unless you are a total CS newbie, you are in the best position to come up with an answer that your 5 year-old can understand. – Stephen C Sep 15 '10 at 05:25
  • 13
    What is with the close votes. Ugh – NullUserException Sep 15 '10 at 05:38
  • 3
    @Null You think a question about the largest number computers can store is "a specific programming problem"? – Michael Mrozek Sep 15 '10 at 06:24
  • If you want to print it in decimal and terminate then the computer needs to count the digits, so 10^2^memory_bits-1 would be a reasonable answer (2^memory_bits nines). – starblue Sep 15 '10 at 18:40
  • I would think the "close" votes would be due to this being, or turning into, a subjective discussion. – WernerCD Sep 26 '10 at 02:44

16 Answers16

47

This question is actually a very interesting one which mathematicians have devoted a fair bit of thought to. You can read about it in this article, which is a fascinating and accessible read.

Briefly, a guy named Tibor Rado set out to find some really big, but still well-defined, numbers by defining a sequence called the Busy Beaver numbers. He defined BB(n) to be the largest number of steps any Turing Machine could take before halting, given an input of n symbols. Note that this sequence is by its very nature not computable, so the numbers themselves, while well-defined, are very difficult to pin down. Here are the first few:

BB(1) = 1
BB(2) = 6
BB(3) = 21
BB(4) = 107

... wait for it ...

BB(5) >= 8,690,333,381,690,951

No one is sure how big exactly BB(5) is, but it is finite. And no one has any idea how big BB(6) and above are. But at least these numbers are completely well-defined mathematically, unlike "the largest number any human has ever thought of, plus one." ;)

So how about this:

The biggest number a computer can represent is the most instructions a program small enough to fit in its available memory can perform before halting.

Squared.

No, wait, cubed. No, raised to the power of itself!

Dammit!

Tom Crockett
  • 30,818
  • 8
  • 72
  • 90
  • 4
    That is a fantastic article link. Thank you! – Yehonatan Sep 18 '10 at 06:33
  • It's not really an input set of n symbols -- that would be symbols already on the turing machine tape. What is really meant here is 10 *rules*, which the turing machine's tape head follows while performing computations on the tape. – Billy ONeal Sep 26 '10 at 02:25
  • This answer is a fantastic article. – peterh May 09 '18 at 20:21
35

Bits are not numbers. You, as a programmer, give them the meaning you want, possibly numbers.

Now, I decide that 1 represents "the biggest number ever thought by a human plus one".

Alexandre C.
  • 55,948
  • 11
  • 128
  • 197
  • 4
    Possibly not in the spirit of the question... :) – annakata Sep 14 '10 at 12:20
  • 3
    surely then `1` is the largest number – Matt Sep 14 '10 at 12:42
  • +1. Very good point. Everybody else seems to think about integers, exclusively. But bits *aren't* numbers - for example, a 64 bit floating point number has a range way greater than 0..2^64-1 – Niki Sep 14 '10 at 17:27
  • 3
    "the biggest number ever thought by a human plus one" is not well-defined... and also computers have probably thought of much bigger numbers than humans ever have ;) – Tom Crockett Sep 15 '10 at 04:33
  • And then I call `A(your number, your number)` (http://en.wikipedia.org/wiki/Ackerman_function) and get something quite a bit larger. Where does it end? – cobbal Sep 15 '10 at 05:27
  • I think the question that first must be answered is "What does it mean to represent a number in a computer?" – Gabe Sep 15 '10 at 05:47
  • This number can't exist, because if it does it immediately allows for a larger number. You're trying to say "infinity", which is really not a good answer. It's a shame the link to Aaronsons article isn't the number 1 post; it is truly a great article. – Noon Silk Sep 26 '10 at 02:24
24

Errr this is a five year old?

How about something along the lines of: "I'd love to tell you but the number is so big and would take so long to say, I'd die before I finished telling you".

Jaydee
  • 4,138
  • 1
  • 19
  • 20
  • 3
    +2 if I could. This is the first answer that actually addresses the question. – Icode4food Sep 14 '10 at 11:55
  • 5
    I wondered about the dieing bit, perhaps "before bedtime" or someting would be better – Jaydee Sep 14 '10 at 12:09
  • 1
    No no no no no, if this child is intelligent enough to ask a great question then he or she shouldn't be told a ridiculously patronising answer. Kids aren't dumb, don't patronise them. Dad - you've done a great thing by coming on here and I hope you went some way to explaining the accepted answer. – Simon Nicholls May 25 '16 at 14:47
20
//  wait to see
for(;;)
{
    printf("9"); 
}
Hernán Eche
  • 6,529
  • 12
  • 51
  • 76
  • 6
    It will stop, just not on its own. – Gabe Sep 15 '10 at 05:43
  • When it stops is that the answer? – Yehonatan Sep 18 '10 at 06:29
  • 3
    That is a relatively small number. Printing 9's will end when the computer gets out of power. That is sometime before the Earth collapses into the Sun, or the Universe collapses, or it disintegrates. The resulting 999...9 is a number way, way, smaller than BB(100). – Adrian Jan 27 '11 at 10:48
  • 2
    @Adrian Fritsch, you are right, anyway same joke still work adding printf("BB("); as first line.. of course, the last one out, please close the parenthesis – Hernán Eche Jan 31 '11 at 12:07
  • @Adrian Fritsch thanks for being interested in this answer, but I really prefer (and I voted for) the Alexandre C. answer.. Anyway if you pay attention you will catch the idea that if you could propose any fixed expression that has a repetitive version, then the algorithm version will be bigger - time is on my side -, perhaps any numeric representation can have a repeated version that will be bigger, then if we would compete in a "limited arena", your simbols have sense, but if arena is unlimited then the simple repetition of the cleverest concept, will be bigger. – Hernán Eche Apr 08 '11 at 15:14
13

roughly 2^AVAILABLE_MEMORY_IN_BITS

EDIT: The above is for actually storing a number and treats all media (RAM, HD, cloud etc.) as memory. Subtracting the OS footprint (measured in KB) doesn't make "roughly" less accurate...

If you want to "represent" a number in a meaningful way, then you probably want to go with what the CPU provides: unsigned 32 bit integers (roughly 4 Gigs) or unsigned 64 bit integers for most computers your kid will come into contact with.

NOTE for talking to 5-year-olds: Often, they just want a factoid. Give him a really big and very accurate number (lots of digits), like 4'294'967'295. Then, once the glazing leaves his eyes, try to see how far you can get with explaining how computers represent numbers.

EDIT #2: I once read this article: Who Can Name the Bigger Number that should provide a whole lot of interesting information for your kid. Obviously he's not your normal five-year-old. So this might get you started in a cool direction about numbers and computation.

Daren Thomas
  • 67,947
  • 40
  • 154
  • 200
  • 7
    Minus the 640K the OS needs. –  Sep 14 '10 at 11:41
  • Hard disks would be available too. ;) – Jeff Mercado Sep 14 '10 at 11:41
  • 2
    Actually it's `(2^(AVAILABLE_MEMORY_IN_BITS+1)) - 1` – Aaron Digulla Sep 14 '10 at 11:44
  • @Developer Art: the phrase "available memory" already takes into account the memory used by the OS and any other currently running program. – slebetman Sep 14 '10 at 11:54
  • kid has plenty of saved files with really big and very accurate numbers. would be tough to beat them. – Yehonatan Sep 14 '10 at 12:03
  • 5
    *"Obviously he's not your normal five-year-old."* - I don't know. 5 year olds are good at asking deep questions like this. The problem is that most 5 year-olds 1) don't realize how deep the question is, 2) don't have the knowledge to be able to understand the answer, and 3) don't have the attention span to even listen to the answer. – Stephen C Sep 15 '10 at 05:31
  • @Aaron - you are assuming that you are talking about arbitrary numbers. For instance, if I'm just representing powers of 2, I can represent numbers up to `2^(2^(AVAILABLE_MEMORY_IN_BITS)))` ... or something like that. – Stephen C Sep 15 '10 at 05:35
  • @Hernan - what is the fundamental difference between "representing" and "storing"? To me, the words are pretty much equivalent in this context. – Stephen C Sep 15 '10 at 05:40
  • @Stephen C: Yeah, but my five-year-old doesn't keep a collection of printed huge numbers in a drawer... and he's probably smarter than the average bear... – Daren Thomas Sep 16 '10 at 06:27
  • @Daren - I was talking in the general case, not the particular. – Stephen C Sep 16 '10 at 07:59
  • @Stephen C - Good question, fundamental difference is same between Generation and Store, Born once vs being still alive, is the medium, in this context "store" means save (recoverable) in a computer, but you can save it outside, in your memory, in a paper, or simply nowhere, throw it to any unrecoverable place, for example using only 1 bit/byte showing a different value with a rate of one per second, like a rolling display that shows something only once, it was represented, but if you don't remember it, it's gone – Hernán Eche Sep 16 '10 at 13:36
5

The answer to life (and this kids question): 42

WernerCD
  • 2,137
  • 6
  • 31
  • 51
3

That depends on the datatype you use to represent it. The computer only stores bits (0/1). We, as developers, give the bits meaning. (65 can be a number or the letter A).

For example, I can define my datatype as 1^N where N is unsigned and represented by an array of bits of arbitrary size. The next person can come up with 10^N which would be ten times larger than my biggest number.

Sure, there would be gaps but if you don't need them, that doesn't matter.

Therefore, the question is meaningless since it doesn't have context.

Aaron Digulla
  • 321,842
  • 108
  • 597
  • 820
2

Well I had the same question earlier this day, so thought why not to make a little c++ codes to see where the computer gonna stop ... But my laptop wasn't with me in class so I used another, well the number was to big but it never ends, i'll run it again for a night then i'll share the number you can try the code is stupid

#include <stdlib.h>
#include <stdio.h>

int main() {
    int i = 0;

    for (i = 0; i <= i; i++) {
        printf("%i\n", i);
        i++;
    }
}

And let it run till it stops ^^

Christos Lytras
  • 36,310
  • 4
  • 80
  • 113
  • We know exactly where it will stop; for a 32 bit system, it will stop at `2,147,483,647` and for a 64 bit system it will stop at `9,223,372,036,854,775,807`. Integers have specific limits depending on the bits the CPU can handle. – Christos Lytras Feb 26 '19 at 16:22
1

Don't know much about theory, but I far as I understood from your question, is: what is the largest number that the computer can represent (and I add: in a reasonable time, and not printing "9" until the Earth will "be eaten by the Sun"). And I put my PC to make one simple calculation (in PHP or whatever language): echo pow(2,1023) - resulting: 8.9884656743116E+307. So I guess this is the largest number that my PC can calculate. On the other side, I think the respresentation of the largest negative number can be: -0,(0)1

LE: That computed value was obataind through PHP, but I tried to figure out what's the largest number that my windows calculator can compute, and it is pow(2, 33219) = 8.2304951207588748764521361245002E+9999. Now I guess this is the largest number my PC can handle.

user3143076
  • 43
  • 1
  • 4
1

The size will obviously be limited by the total size of hard drives you manage to put into your PC. After all, you can store a number in a text file occupying all disk space.

You can have 4x2Tb drives even in a simple box so around 8Tb available. if you store as binary, then the biggest number is 2 pow 64000000000000.

1

If your hard drive is 1 TB (8'000'000'000'000 bits), and you would print the number that fits on it on paper as hex digits (nobody would do that, but let's assume), that's 2,000,000,000,000 hex digits.

Each page would contain 4000 hex digits (40 x 100 digits). That's 500,000,000 pages.

Now stack the pages on top of each other (let's say each page is 0.004 inches / 0.1 mm thick), then the stack would be as 5 km (about 3 miles) tall.

Thomas Mueller
  • 48,905
  • 14
  • 116
  • 132
  • You're assuming an uncompressed integer representation. Using floating point you can get much bigger, and compressing will get you much bigger still! – Gabe Sep 15 '10 at 05:50
  • Using the above formula, you can calculate the size of the stack for other devices (cell phone, iPod, TV, and so on). But it's hard to get the number for the internet. – Thomas Mueller Sep 16 '10 at 10:28
  • +1 for a visual explanation. i would use dec instead of hex tho. – Yehonatan Sep 18 '10 at 06:42
  • I thought about using decimal instead of hex, but the formula was getting too complicated :-) – Thomas Mueller Sep 18 '10 at 07:24
1

I'll try to give a practical answer.

Common Lisp number crunching is particularly powerful. It has something called "bignums" which are integers that can be arbitrarily large, limited by the amount of available.

See: http://en.wikibooks.org/wiki/Common_Lisp/Advanced_topics/Numbers#Fixnums_and_Bignums

Joubert Nel
  • 3,154
  • 3
  • 26
  • 24
1

I think you should be very proud that your 5 year old is already asking questions like this. And you should continue to promote that! This is truly amazing! With that said, I would say that saying Infinity does not count is thinking incorrectly about what numbers mean in computer memory. I feel like this way of thinking is a handicap.

Mathematicians will never be able to write out ALL the digits of pi or eulers number, BUT we FULLY understand it. Pi, as an example, is perfectly represented by infinite this series: (Pi / 4) = 1 - 1/3 + 1/5 - 1/7 + 1/9 - …
Just because you literally can’t go to inf. or print every single digit in a console means nothing. You could have printed the symbol representing pi and therefore capturing the inf. series. Computer Algebra Systems (CAS) represent numbers symbolically all the time. Pi, for instance, may be a Symbolic object in memory (the binary in memory did not DIRECTLY represent the number. It represents an "mathematical algorithm" for producing the answer to arbitrary precision). Then you do some math with it, transforming from one expression to the next. At no point in time did we not represent the number COMPLETELY.

At the end, you can do 2 things with this:

A) Evaluate the expression, turning it into a number of some kind (or Matrix or whatever). BUT this number could very well be an approximation (say like 20 digits of pi).

B) Keep it in its symbolic form for reference. Obviously we don’t like staring at symbols because we need to eventually turn the nobs on the apparatii. NOTE: sometimes you can get a finite (non-irrational) number perfectly represented in memory (like number 1) by taking limits or going to inf. Not literally having an inf. number in memory, but symbolically representing it. Just throw this in Wolfram alpha: Lim[Exp[-x], x --> Inf]; It gives you the number 0. Which is EXACT.

In short:

It was the HUMANS need to have some binary in memory that DIRECTLY represented the number that caused the number to degrade. Symbolically it was perfectly represented. You could design some algorithm that just continues to calculate the next digits of pi or eulers number giving you an arbitrary amount of precision (Now, this is obviously not practical of course).

I hope this was at least somewhat useful or interesting to you, even if you disagree =)

Tyler Heers
  • 134
  • 4
0

Depends on how much the computer can handle. Although there are some times when the computer can handle numbers greater than (2^(bits-1)-1)... For example: My computer is 64 bit (9223372036854775807), however the calculator that comes with the computer itself can handle numbers of up to 10^9999.

Many other supercomputers can exceed these limits, and the one with the most memory (bits) might as well be the one with the record (current largest number that can be held by computers).

Or, if it comes to visually seeing it on computers, you can just make a program that, on monitor, repeats writing 9 and not skips that line to form an ever-growing bunch of 9. :P

0

I came here looking for the largest number I can convey using standard knowledge in a limited amount of space I decided on 8 characters. I settled on this. 'FF^FFFFF' Although it requires unpacking, this is the largest number I have found that can be expressed in 8 characters. This is equivalent to 255^1,048,575. This is approximately 7.41 * 10 ^ 2,523,437. This is 741 with 2,523,435 zeros. This dwarfs the number of protons in the observable universe. A mere 80 decimal places.

Anon
  • 1
-1

go on chrome then go on three dots above and click them then go on tools and then go on developer tool click on console and type Number.MAX_VALUE