# Preliminary Concepts: Binary Numbers

Computers operate by using millions of electronic switches (transistors), each of which is either on or off (similar to a light switch, but much smaller). The state of the switch (either on or off) can represent binary information, such as yes or no, true or false, 1 or 0. The basic unit of information in a computer is thus the binary digit, or bit. Although computers can represent an incredible variety of information, every representation must finally be reduced to on and off states of a transistor. Let's start with representation of numbers, perhaps the simplest information to represent in a computer.

When you see the string of digits 1297, you most likely interpret this as "one thousand two hundred ninety-seven." You use the base-10 system (although not all cultures in history have done so), which means the right-most digit represents the number of "ones," the next digit to the left represents the number of "tens," then "hundreds," and so forth. More formally, we could write the string as:

 1 x 1000 plus 2 x 100 plus 9 x10 plus 7 x 1

Notice that each place to the left represents a higher power of 10 (the base).

Binary numbers work similarly, but with 2 as the base. For example, the string 10010 in binary is interpreted as follows:

 1 x 16 plus 0 x 8 plus 0 x 4 plus 1 x 2 plus 0 x 1

which is eighteen. Another example is 101, which is interpreted as:

 1 x 4 plus 0 x 2 plus 1 x 1

This is five. Using binary numbers, we can store any whole number in the computer, as long as we have enough transistors (switches) to represent all the bits. Many microprocessors use 32 bits to represent numbers, which means they can store any value from 0 up to 4,294,967,295. If larger numbers are needed, then more switches must be used to represent the additional bits. Let's count, starting from 1 in both base-10 and base-2:

Base-10 Base-2
0
0
1
1
2
10
3
11
4
100
5
101
6
110
7
111
8
1000
9
1001
10
1010
11
1011
12
1100
13
1101
14
1110
15
1111
16
10000
17
10001

In base-10, there are ten digits (0 through 9) and after these are used, a new place (the 10s place) must be added to the left. In base-2, there are two digits (0 and 1), after after these are used, a new place (the 2s place) must be added to the left. One more note: notice the pattern running vertically in the base-2 count. The right-most column alternates 0, 1, 0, 1, 0, 1. . . . The next column alternates two 0s and then two 1s: 0, 0, 1, 1, 0, 0, 1, 1. . . . The next column alternates four 0s and then four 1s, and so on.

These pages were written by Steven H. VanderLeest and Jeffrey Nyhoff and edited by Nancy Zylstra