views:

915

answers:

12

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.

+11  A: 

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
Minus the 640K the OS needs.
Developer Art
Hard disks would be available too. ;)
Jeff M
Actually it's `(2^(AVAILABLE_MEMORY_IN_BITS+1)) - 1`
Aaron Digulla
The question says "represent", not to store..
Hernán Eche
@Developer Art: the phrase "available memory" already takes into account the memory used by the OS and any other currently running program.
slebetman
kid has plenty of saved files with really big and very accurate numbers. would be tough to beat them.
Yehonatan
*"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
@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
@Hernan - what is the fundamental difference between "representing" and "storing"? To me, the words are pretty much equivalent in this context.
Stephen C
@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
@Daren - I was talking in the general case, not the particular.
Stephen C
@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
+1  A: 

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.

Developer Art
Actually I would say the size of all available storage to the machine, not just its disk.
Woody
Well, if you use a text file, then your number won’t be as big as if you had used a binary file.
Konrad Rudolph
What about the cloud?
Drew Hall
What about it?.
Developer Art
what about using the number of atoms in universe?
Yehonatan
The atoms of universe are not available in a PC. Only a really small portion of them.
Developer Art
Woody: What about if you use compression?
Gabe
+24  A: 

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.
Jon Skeet would say that.
Yehonatan
I like this answer +1
Hernán Eche
Possibly not in the spirit of the question... :)
annakata
surely then `1` is the largest number
Matt Joslin
+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
nikie
"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 ;)
pelotom
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
I think the question that first must be answered is "What does it mean to represent a number in a computer?"
Gabe
`1` is the loneliest number.
hydrogen
This goes recursively... your application would produce stack overflow...
The King
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
+15  A: 

// wait to see

for(;;)
{
    printf("9"); 
}
Hernán Eche
but it never stops
Yehonatan
That is the point
mikek3332002
It will stop, just not on its own.
Gabe
When it stops is that the answer?
Yehonatan
Any other digit except 0 also works :)
Lucas
A: 

Inifinity minus one, because infinity is signed - infinity can be positive OR negative. :-)

AndrewJacksonZA
+∞ then. [ ](http://.)
KennyTM
Infinity - 1 = Infinity. No matter what sign it has
nikie
Downvote: You cannot subtract from the infinity. :(
Crozin
infinity not allowed with kid
Yehonatan
@Yehonatan: Inifinity - 1 != Infinity.
AndrewJacksonZA
Infinity - 1 *is* infinity.
JeremyP
@AndrewJackson: `Inifinity - 1 != Infinity` is only true for finite values of the variable `Infinity`. Look it up.
nikie
-1. If `∞ - 1 = x` then `x + 1 = ∞` which sort of makes `x` the 'largest finite number'. That breaks a whole lot of math. I call BS.
aaronasterling
@AaronMcSmooth: x is not the 'largest finite number', x is infinity.
sixtyfootersdude
+2  A: 

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
+16  A: 

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
+2 if I could. This is the first answer that actually addresses the question.
Icode4food
explaining death would be more tricky...
Yehonatan
I wondered about the dieing bit, perhaps "before bedtime" or someting would be better
Jaydee
+4  A: 

Computer can represent any number you can imagine.

fhucho
hard to believe that
Yehonatan
pi....................
JeremyP
That was stupid, me smugly thinking computers can't do transcendental numbers when the two letters p and i are sitting there next to each other in a browser window on my computer and everybody knows exactly which number they are representing.
JeremyP
But they can't represent all of them at the same time !
Alexandre C.
@Yehonatan You can try that - imagine some number and than create a program that reads a bit from memory. A number is encoded in that bit this way: if the bit is 0, the number is 0; if the bit is 1, the number is the one you imagined.
fhucho
If you use haskell, this is true (due to lazy evaluation). Bould I would say: Each number which is defined in a finite amount of memory.
FUZxxl
@fhucho that would mean 1 represents all numbers.
Yehonatan
@Yehonatan That's right, 1 _can_ represent all numbers, it depends on the program how it interprets/decodes the "1".
fhucho
@fhucho but I'm more concerned how the kid (or we) interpret/decode the 1.
Yehonatan
+1  A: 

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
You're assuming an uncompressed integer representation. Using floating point you can get much bigger, and compressing will get you much bigger still!
Gabe
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
+1 for a visual explanation. i would use dec instead of hex tho.
Yehonatan
I thought about using decimal instead of hex, but the formula was getting too complicated :-)
Thomas Mueller
+24  A: 

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!

pelotom
That is a fantastic article link. Thank you!
Yehonatan
Great article indeed.
serg
Agree the article is great!!
Hernán Eche
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
+1  A: 

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
A: 

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

WernerCD