CS 100 (Learn)CS 100 (Web)Module 01


Why use Binary?

(direct YouTube link)

NOTE: If your internet access is restricted and you do not have access to YouTube, we have provided alternate video links.

TRANSCRIPT

You've probably heard that digital data is stored and represented in binary, which is made up of just ones and zeros.

You might have also wondered... why? Why not use all of the digits from zero through nine? It might seem that it would be a lot easier just to use them all. To motivate this we're going to use an espionage example.

Let's pretend that you're a spy and you want to communicate or transmit information to another spy. You don't want to blow your cover, and so you can't be seen together.

The system of communication you have decided to use is to put a light in your window than can be seen from the street. Your fellow spy can simply walk past your window and see if the light is "on" or "off". We're using this example not only because it's illustrative, but because actual spies have used this communication method. Drug dealers have also been known to use similar techniques, but we don't know anything about that.

With this method, you can communicate two different messages. Of course, you would to agree in advance what the messages mean. Perhaps when the light is "on" it means "go ahead with the assassination" and "off" means "don't go ahead with the assasination -- just chill". Or perhaps when the light is "on" it means "I have drugs for sale", oh... never mind.

One problem with this system is that you can only communicate two different messages, or for reasons that will become clearer, two different values. What if you need to convey more possible values?

Well, you might be inclined to hook the light bulb up to a dimmer and then you could use varying degrees of brightness to communicate different values. For example, we could convey four different values with four different brightness settings: completely off, dim, medium bright, and fully on.

You can probably already see the inherit problem with this system. With four different brightness levels, how confident are you that the other spy can tell the difference between "dim" and "medium bright"? What if it's a rainy day, or a really bright day?

Instead, a better approach is to throw away the dimmer and put two lights in the window. With two lights we can convey four possible values, corresponding to: off-off, off-on, on-off, and on-on.

If we put three lights in the window there would be eight different values.

If we have "k" lights, then there would be two to the k [2k] different values. The base is two because there are two states for each light: "on" or "off".

So why is digital information stored and represented with binary? Because it's really easy to determine if something is "off" or "on". If we were to build computers to use ten digits instead of two, it would be like using ten different levels of brightness. That would require digital electronics and storage devices to be much more sensitive.

Let's say we want to represent about one thousand [1000] different values. With binary, we would need ten different lights. With decimal we would need only three lights. Sure, we need more lights with binary, but not that many more lights. More importantly, each light is simpler, less expensive to produce and can be read more accurately.

Binary information is really just like a whole bunch of light switches that are either off or on. When they are off, it corresponds to zero, and when they are on they correspond to one. This representation (off is zero and on is one) is actually pervasive throughout our society and it has been adopted in many ways you may not have ever noticed. For example, light or power switches often use zero and one to indicate whether it is off or on, and when you can use the same button to turn a device on or off they actually use a logo that shows a one and a zero combined together. You've probably seen that logo many times and not realized that it's a one and a zero.

If you have a hard time remembering which number (zero or one) is on, remember that in English the number one has the word "on" right inside of it.

In computer memory, digital information is literally stored in tiny circuits that are either off or on. They aren't little tiny light switches, but their function is surprisingly similar.

Digital information can also be stored on a wide variety of physical media. On hard drives and floppy disks, the off/on information is stored in small areas that are either magnetized or de-magnetized. On USB Drives and SD Cards, the information is stored as electrical charges that are kind of like static electricity. On CDs and DVDs and Blu-Rays the off/on information is stored as little pits on the surface of the disc. In all of these physical media, there is a clear way to indicate two different values.

It is this characteristic: the ability to easily distinguish between two distinct values, which is why binary is an excellent choice to represent and store digital information.