Understanding Binary Code

This is all very simple really. We'll take it one step at a time. First, binary code is
also known as Base Two (bi means two, as in **Bi**cycle or **Bi**lingual).
Computers use Base Two because all of the work is done by transistors; tiny switches with
no moving parts. The switches can either be OFF (0) or ON (1). Check out the power switch
on your appliances at home. Many of them will show 0 and 1 (off and on). Learning Base Two
is easy and fun. In order to proceed, you must first understand how number systems work.
There are basically two rules:

1. There are "x" numerals.

2. Each place value is "x" times larger than the one to its right.

*Let's take a quick look at Base Ten, the number system that we use in daily life. *

1. There are ten numerals. 0123456789

2. Each place value is ten times larger than the one to its
right. __thousands__ __hundreds__
__tens__ __ones__

The largest numeral that can be put into a place is 9. If you want to get bigger, you have to move over to the next place value. (That's why, in Base Ten, you can multiply a number by 10 just by adding a 0. You are moving everything over 1 place)

All number systems work this way. Duh. If you are 13 years old, you are really 1 ten and 3 ones. But you knew that.

In Base Two, things work like this:

1. There are two numerals. 01

2. Each place value is two times bigger than the one to its
right. __eights__ __fours__ __twos__
__ones __

The largest numeral that you can put into a place is 1. If you want to get bigger, you have to move over to the next place value.

If you are 13 years old (Base Ten), you would be 1101 in Base two; 1 eight, 1 four, 0 twos, and 1 one. Add them. If you think this is weird, be glad that you are not 101110 like me! Here's what the place values look like to a computer. Each place value represents a switch (on or off). Each one is called a bit, and the computer reads them in packs of 8 (byte).

128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |

Did you notice that the place values go up like the newest version of Nintendo or Sega? This is not an accident; they read binary also! A byte that contains the number 13 would look like this: 00001101

0 |
0 |
0 |
0 |
1 |
1 |
0 |
1 |

128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |

To convert a Base Ten number to Base Two, first make a place value guide to keep you from getting lost.

128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |

Let's convert the number 46. First, determine what would be the biggest switch (place value) that you could turn on without going over? That's correct: 32. Now, put a 1 in the 32s place to turn on that switch.

1 |
|||||||

128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |

Now, 32 has been used up, so how much is left? 46-32=14 So, what is the next biggest switch (without going over, remember) that we can turn on? That's right, the 8 switch!

1 |
1 |
||||||

128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |

How much is left? 14-8=6 The next biggest switch we can turn on is the 4s switch.

1 |
1 |
1 |
|||||

128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |

How much is left? 6-4=2 We turn on the 2s switch.

1 |
1 |
1 |
1 |
||||

128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |

What's left? 2-2=0 There is nothing left, so fill the remaining places with 0 (off).

0 |
0 |
1 |
0 |
1 |
1 |
1 |
0 |

128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |

So, the number 46 looks like this as a byte: 00101110

Not sure is it is correct? Add up the places that are turned ON. 32+8+4+2=46

Whew! Remember when I said it was really very simple? I didn't say it was fast! The processor in the computer, however, can read millions of switches in a second. Not smart, but fast.

Think you've got it? Take the quiz** **. You can print a
worksheet, but you can probably make a better
one yourself. REALLY understand? Try to apply the rules and convert your age
to Base Five, or Seven, etc.

Would it be cheating to use the calculator in your computer to
check the answers and help with subtraction? Not to me it wouldn't, so if you need a
calculator, click the **Start** button on the task bar, then choose **Programs**,
then **Accessories**, then **Calculator**.

After you take the quiz (and you did well), go to the ASCII Code page and see how the computer interprets what you type and converts it into ASCII and then to binary code.

*Steve Harrell*

*11/99*