CPS100 • Introduction to Computers


Lakeland College • Japan Campus


Binary Counting

Human beings use a base-10 counting system, possibly because we have ten fingers. In fact, the word for a single-character number is "digit," the same word we use for "finger." We have ten fingers, and we have 10 digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, and 0.

Computers, however, only have two "fingers." Computers count with switches. If the switch is off, that's a "0." If the switch is on, that's a "1." Therefore, computers count with a system that has only two digits. It is called "base two," or binary.

In this chapter, let's begin with the vocabulary:

Terms to Know

digita single character representing a specific value; for example, in the number "5734" there are four digits. In this case, the digit "5" represents the value of (5 x 1000).
numberone or more digits which express a total value.
to countto add one to a number; the "one" is always added to the right-most digit (the "ones column"). When a column has reached the highest digit, it returns to zero, and the next column to the left is added to.


How do we count?

This is simple. We all learn to count as children. We do it so naturally that we don't even think about it. However, to learn a new counting system, you have to really think about and understand our counting system. What are the rules?

Take 19 plus 1 equals 20, for example. You think, of course 19 + 1 = 20. However, think about it for a moment. 9 + 1 = 0? Why are both digits changed? You might know it, but it is probably really hard for you to explain it.

The basic system is simple. Start with "0." Add 1. No problem, right? You can do that all the way to 9 very simply. 1 + 1 = 2. Simple! 2 + 1 = 3. Easy! 3 + 1 = 4. I'm getting bored.

However, what happens when you get to 9? Nine is the highest digit. There is no single-character number higher than 9.

Here is where we begin using columns. After you reach 9 and you add 1, the 9 must become a 0; in addition, we must add 1 to the next column to the left. Therefore, 9 becomes 10. 19 becomes 20. 89 becomes 90.

So there is a simple but important rule of counting: Add one until you reach 9, then go back to 0 and add 1 to the next column.

Mr. Poza, You Are So Stupid!

Of course you know how to count! However, these rules are used for other counting systems which will seem strange. Knowing the rules will make it easier.

There is one more rule you should follow: what the columns mean. Let's take the number 5,362. What does each digit mean? Is the "5" just a "5"? Does the whole number mean "5 + 3 + 6 + 2"? Of course not. Here's how it works:

millions hundred thousands ten thousands thousands hundreds tens
[BASE]
ones
1,000,000 100,000 10,000 1,000 100 10 1
106 105 104 103 102 101 100
0 0 0 0 0 0 0
1 1 1 1 1 1 1
2 2 2 2 2 2 2
3 3 3 3 3 3 3
4 4 4 4 4 4 4
5 5 5 5 5 5 5
6 6 6 6 6 6 6
7 7 7 7 7 7 7
8 8 8 8 8 8 8
9 9 9 9 9 9 9

In fact, the 5 is in the column valued at 1000; the 3 is in the 100s column; the 6 is in the 10s column; and the 2 is in the 1s column. To get the actual values, we must multiply the digit by the value of the column.

Put another way:

(5 * 1000) + (3 * 100) + (6 * 10) + (2 * 1)

One more thing: notice that I have labeled "10" as the base number column. The second column from the right is always the base, and is x1. That number is always equal to the number of digits used by the system. For example, if we use base 16, then that system has 16 digits and the second column represents 161, which is 16.

All the columns are based on that one number. In base ten, we have 100 (102), 1000 (103), 10,000 (104), and so on.

All of that is understandable, right?

Base 2 • Binary

OK, now let's remember those rules so we can use them in binary:

  1. The base number is in the second column from the right (e.g., 10);
  2. All columns are based on the base number (102, 103, etc.);
  3. A digit in each column equals the digit times the column value (5 x 1000);
  4. To count, add 1 to the right-most digit (6 + 1 = 7)
  5. If a digit is already the highest digit, it becomes 0 and we add one to the next column to the left (19 + 1 = 20).

OK! Now, let's use those rules in a base 2 counting system:

sixty-fours thirty-twos sixteens eights fours twos
[BASE]
ones
64 32 16 8 4 2 1
26 25 24 23 22 21 20
0 0 0 0 0 0 0
1 1 1 1 1 1 1

So, let's follow the rules:

Rule #1: The base number is in the second column from the right. In this case, the base number is 2.

Rule #2: All columns are based on the base number. In this case, just multiply by 2 every time: 2, 4, 8, 16, 32, 64, etc.

Notice that 20 = 1. Remember that 100 also = 1! Math trick: any number to the 0th power equals 1! So in any system of counting, the first column will always be a "ones" column.

Rule #3: A digit in each column equals the digit times the column value. Let's say you have the number 10101, as shown in the table above. The value of that number would be:

(1 * 16) + (0 * 8) + (1 * 4) + (0 * 2) + (1 * 1)     =     16 + 4 + 1     =     21.

Rule #4: To count, add 1 to the right-most digit. In base 2, you begin with 0. Then you add one, to get 1. That is the same as usual.

Rule #5: If a digit is already the highest digit, it becomes 0 and we add one to the next column to the left. This is where people get confused. We are used to going "0, 1, 2, 3..." but here, we go "0, 1" and that's it! After that, we have to start a new column! Let's count to 10 in base 2 and see how it looks:

binary base 10
0000 0
0001 1
0010 2
0011 3
0100 4
0101 5
0110 6
0111 7
1000 8
1001 9
1010 10

Every time a column becomes a "1" it is the highest possible digit. When you add 1 to that, it must become 0 and send the "1" to the left. This is the same as the number 19, where adding 1 changes the 9 to a "0" and you send the "1" to the left, to make 20.

People get confused because they think in base 10. If you see "10," that's ten!! However, in base 2, "10" is really two. "11" is 3. "100" is four. Just remember: the columns are not 1000-100-10-1; the columns are 8-4-2-1.

To translate from base 2 to base 10 is easy—just write out the base numbers in reverse order (512, 256, 128, 64, 32, 16, 8, 4, 2, 1) and every time a "1" appears, add the number column it comes from.

For example, take the number 1011001010:

512 256 128 64 32  16  8  4  2  1
 1  0  1  1  0  0  1  0  1  0

512     +     128     +     64     +     8     +     2     =     714

Converting from base 10 to base 2 is a little harder, but not much. Again, you have to have the binary numbers ready. You begin by subtracting the largest binary power number from the number you have.

For example, if you want to translate 413, you begin by checking if you can subtract 512 from it. The answer is "no," so you put a "0." However, you can subtract 256; so you put a "1" next, and subtract 256 from 413, which leaves 157.

Continue the sequence. Can you subtract 128 from 157? Yes, so add another "1" and 157-128=29. Can you subtract 64 from 29? No, so add a "0"; 32 also cannot be subtracted, so another "0." Next, you can take 16 from 29 (29-16=13, add a "1"), you can take 8 from 13 (13-8=5, add a "1"), you can take 4 from 5 (5-4=1, add a "1"). You cannot take 2, so add a "0," and you are left with a final "1."

As a result, you get the number "0110011101," which equals 413 in binary.

413 - 512? No -- 0
413 - 256? Yes Leaves 157 1
157 - 128? Yes Leaves 29 1
29 - 64? No -- 0
29 - 32? No -- 0
29 - 16? Yes Leaves 13 1
13 - 8? Yes Leaves 5 1
5 - 4? Yes Leaves 1 1
1 - 2? No -- 0
1 - 1? Yes Leaves 0 1

Tech in Your Life

You Have Seen These Numbers Before

Look at the numbers we get for the powers of "2": 1, 2, 4, 8, 16, 32, 64, 128, 256, 512. Do they look familiar? They should—you see them all the time in the computer world. If you have a USB flash memory stick, get it out and read the capacity (size). It will have one of those numbers (e.g., 512 MB, 4 GB, 16 GB). You may have heard of 32-bit or 64-bit operating systems, or your computer may have 8 GB of RAM. These numbers are often used in computers, especially to describe amounts of memory (not storage).



 

Watch this YouTube video I created to help understand binary counting and why it is connected to computers:



 


Try using this binary - base 10 conversion app to see how binary numbering works:


Previous Chapter Chapter Quiz Next Chapter