Why does everything in computing work with a base number of 2 to the power of x?

1. Flash-drive sizes (increase by powers of 2)
2. RAM size (increase by powers of 2)
3. 32bit, 64bit, 128bit (increase by powers of 2) etc...

Can someone explain this, I think it might have something to do with device compatibility and also binary code in which case could you explain why these devices have to follow this binary code sequence ?

Also, how many fingers do computers have?

-
It doesn't. Ternary computers were developed too. – AndrejaKo Nov 16 '11 at 11:56
In ancient times, there were even computers using decimal numbers just like we humans do. – DarkDust Nov 16 '11 at 12:13
This is really one for elsewhere - eg: en.wikipedia.org/wiki/Binary_numeral_system – Linker3000 Nov 16 '11 at 13:45

Digital electronics used in computers have two states: on and off. So storage of numbers in memory is made up of collections of elements each of which is on or off.

So one element can therefore only represent the numbers 0 and 1 (two values).
If you combine two of these you can now represent 2 to the power of two (four) numbers 0…3.

• off, off = 0
• off, on = 1
• on, off = 2
• on, on = 3

If you have three elements you can represent two to the power of three (eight) numbers 0…7.

• off,off,off = 0
• off,off,on = 1
• off,on,off = 2
• off,on,on = 3
• on,off,off = 4
• on,off,on = 5
• on,on,off = 6
• on,on,on = 7

And so on.

The element might be a switching transistor or something equivalent which is in an on or an off state, it could be a tiny patch of hard disk surface that is magnetised parallel or perpendicular to the direction of rotation (two states).

Hence everything naturally is organised in powers of two.

We only use powers of 10 because we have ten fingers (including thumbs), Computers don't.

-
+1 for pointing out that computers have only 2 fingers... – Vineet Menon Nov 16 '11 at 11:54
It's a shame we didn't just use the 4 fingers on each hand and use powers of 8. – DisgruntledGoat Nov 16 '11 at 13:34
@DisgruntledGoat: What would you get rid of? Thumbs, and become non-opposable? Index fingers, and not point? Middlefinger, and give up satisfying road rage? Ring finger, and give up digit ratio? Pinky, and give up pinky swears? – surfasb Nov 17 '11 at 3:55
@surfasb uh...what? I'm saying we could have only counted the 4 main fingers, not cut 2 fingers off :S – DisgruntledGoat Nov 17 '11 at 10:37

Also, how many fingers do computers have?

Computers only have one finger... However, that doesn't tell the whole story, since computers also usually have a lot of hands (like 32 or 64 in most computers ;).

By definition, anything digital "is a data technology that uses discrete (discontinuous) values." We can represent said discrete values in real-world electronics by using transistors as digital switches. Transistors, when used in switching mode, can either let current flow or not. Thus, we can represent the output of a transistor as either ground (no connection, 0V), or the supply voltage (or some percentage of) - the equivalents of false and true from boolean logic.

To use these discrete states to represent numeric values, we see that each transistor can represent two discrete states - or a number from 0 to 1. This is part of the base 2 number system, which follows the same steps as our base 10 system (and base 3, 4, 5, base 16, and so on and so fourth). If we represent the number 52 in these various number systems, where each digit can range from 0 to N-1, where N is the base of the number system, we have:

``````Base 2:           1   1   0   1   0   0                 110100_2
2^5 2^4 2^3 2^2 2^1 2^0

Base 4:                       3   1   0                    310_4
4^2 4^1 4^0

Base 10:                         5    2
10^1 10^0                   52_10

Base 16:                         3    4                    34_16
16^1 16^0
``````

Now, in the case of binary numbers, you can see that we can represent exponentially larger numbers (like every other number system), by adding more digits - or in the digital computer case, by adding more discrete transistors in parallel with the system. This is why a 32-bit (unsigned) integer can store any number from 0 to (2^32) - 1.

Again, since we can only represent two discrete states electronically, the only way for us to represent more is to extend these states with more "on-off" states, or by adding more base-2 numbers in parallel. This is why everything in the computer world is based off of powers of two - this is the only way we can represent values in a computer.

It should be noted that this is incredibly different then an analog computer, which literally can have an infinite number of state values. This introduces precision errors into values, which are unavoidable - also why digital computers are preferred (less information entropy, better ways of storing, compressing, encrypting, and no information degradation).

It should also be noted that we use base 2 numbers because our transistors can only have two states. If we were capable of making three-state (I'm not talking about tri-state logic here, which simply uses a high-impedance state) or four-state transistor, then we could surely create computers using a different number system.

However, binary is the "tried and true", and there is no real advantage to using a different number system aside from the fact that you might need to use less discrete components to store as many values. For example, when we turned 52 into the base-4, base-10, and base-16 equivalents, you can see that as the base of the number system increases, naturally the number of individual digits required to hold that number decreases.

However, transistors are cheap, small, and tiny - so we have no problems representing very large values (which is also why we've made the switch to 64-bit computing - we can do more operations on larger numbers in less time).

-

Probably the main reason is that it's easiest to work with on the hardware level. It's easy to represent two states with power on or off (or low power vs. full power), but it would be harder to do with, say using and correctly interpreting 10 different voltage levels.

Next are the logic components: components like gates (NOT, AND, OR, XOR, NAND, NOR) are easy to understand and use and can be combined to generate higher order components (like flip-flops or at the very extreme end, a CPU). The math behind that is very well understood (Boolean algebra).

There were computers working with decimal system (the "ten" based system you usually use) with the most famous one being ENIAC but they probably proved too complex and inefficient.

-

They all depend on binary code made up of 1's and 0's and each bit you add to a binary number doubles it.

1111 can be 0000 to 1111 or in decimal 0 to 15 : this is 16 combinations.

11111 can be from 00000 to 11111 or 0 to 31 : this is 32 combinations and so on

Making them in decimal numbers would just "waste" some of these numbers used at machine code level to address memory or provide coded information so would be inefficient.

-

Data is stored in BITs (Binary digits).
1 binary digit can have one of 2 values, 0 or 1. 2 values is 2^1

2 bits (bit 0 and bit 1) can hold 4 values 00 01 10 11 . twice what one bit can hold.

3 bits can hold twice what 2 bits can.. Because when the third bit is 0, the remaining 2 have 4 values, and when the third bit is 1, the remaining 2 bits have 4 values. So, for 3 bits we get 8 values. 2^3=8

2^number of bits = number of values.

It's not just bits that work by that pattern. of base^n

Decimal digits, how many decimal numbers do you get for 3 decimal digits? 10^3=1000 0 up to 999

1-999 are 999 values. and 0 is another value. That's 1000 values. 0-999.

'cos remember, how many numbers between 1 and 10(inclusive)? 10. How many values between 0 and 10 (inclusive), well, there'd be 11 !

2 bits hold 4 values.. representing the numbers 0 to 3. Just like 2 decimal digits hold 100 values 0..99

-

Because if you have a memory you have to address it so you can find which memory cell to store and retrieve values from. An address has to be some number of bits long, lets say x. If you have x bits then you can represent any one of 2x unique values with them. So if you use x bits addresses, you might as well make the memory 2x locations in size.

-