Concept: Binary Numbers
Computers work with numbers. Whether counting internet packets on the network or balancing your checkbook, a computer needs to use numbers. The problem: computer's only know 1's and 0's. The solution: binary numbers.
- Note: Previously, we used the terms true and false which fit for talking about logic gates. However, now we'll switch over to one and zero which fits better when doing arithmetic. Just keep in mind that true=1=on and false=0=off.
Say we have three wires, it's easy to decide how to represent zero.
Then for number one we could use 001, but what about two? 011 could work, and then 111 for three. With this scheme, to count above 3 we'd need more wires. But there are a few combinations that we haven't used yet, like 101 or 010.
To figure this out let's step back: How do we count in decimal using only three digits? After we hit 009 we start over with 010 then up to 019. So every time we get to the biggest digit we just increase the digit to the left and start over. So with just three spaces we can count all the way to 999.
A wire holds one "bit". Whereas a digit can be 0-9, a bit can only be 1 or 0. We can't count up to nine with one bit, but we can use the same idea as counting in decimal. When we get to the highest bit, that is 1, we'll just increase the next wire to the left and start over.
Now we've counted to three, but still haven't even used the third wire. As we can see in the following table, with three wires we can count from zero to seven.
decimal | binary |
0 | 000 |
1 | 001 |
2 | 010 |
3 | 011 |
4 | 100 |
5 | 101 |
6 | 110 |
7 | 111 |
And so we have a system to count using only ones and zeros. The following diagram shows at the bottom the digital (base 10) number that the top binary (base 2) wires define. Try clicking on the top boxes to toggle each bit between 1 and 0.
The following table gives a reference on some more numbers.
decimal | binary |
0 | 0000 0000 |
1 | 0000 0001 |
2 | 0000 0010 |
3 | 0000 0011 |
4 | 0000 0100 |
5 | 0000 0101 |
6 | 0000 0110 |
7 | 0000 0111 |
8 | 0000 1000 |
9 | 0000 1001 |
10 | 0000 1010 |
11 | 0000 1011 |
12 | 0000 1100 |
13 | 0000 1101 |
14 | 0000 1110 |
15 | 0000 1111 |
16 | 0001 0000 |
17 | 0001 0001 |
18 | 0001 0010 |
19 | 0001 0011 |
20 | 0001 0100 |
21 | 0001 0101 |
22 | 0001 0110 |
23 | 0001 0111 |
24 | 0001 1000 |
25 | 0001 1001 |
26 | 0001 1010 |
27 | 0001 1011 |
28 | 0001 1100 |
29 | 0001 1101 |
30 | 0001 1110 |
31 | 0001 1111 |
32 | 0010 0000 |
. . . | . . . |
254 | 1111 1110 |
255 | 1111 1111 |
Next Up: Adder »
Further study
- Binary Numbers in 60 Seconds video—a quick explanation of how to convert between decimal and binary.