Unlocking the World of Binary: A Fresh Approach for New Learners

Unlocking the World of Binary: A Fresh Approach for New Learners

Have you ever struggled with teaching binary notation to non-experts or even understanding it yourself? I'll share how I've taught it to first-year students, elementary school kids, my sister, and my wife (both of whom are in the humanities), and I hope my approach will help.

The reason you struggle with binary is that you understand numbers the wrong way. We all do. Once you realize this, binary notation will become clear to you. Consider the number one hundred seven. You intuitively understand that the three words "one," "hundred," and "seven" add up to the number 107, and you intuitively understand how large or small that is. For example, you know that 107 bars of chocolate is a lot of chocolate, but 107 dollars is not a large salary. But this intuition gets in the way of understanding other numbering systems.

Consider a factory that packages chocolates. This factory packages ten bars into a pack, ten packs into a box, and ten boxes into a crate. And this packaging happens automatically by machines. When there are 9 bars in the machine's temporary storage and one more bar appears on the conveyor belt, they are all packaged into a pack and put into a different conveyor belt. Similarly, when 9 packs are in the temporary storage of the next machine, and one more pack appears in the conveyor belt, they are automatically packaged into a box. Now, let's go back to 107. Can you have 107 bars of chocolate in that factory? I would argue that no, you cannot. You can have one box, zero packs, and seven bars, but not 107 bars. Do you see the difference? Intuitively it seems the same, but if you were programming the packaging machines, the number 107 is meaningless. No packaging machine will ever have to deal with this number. The only numbers that matter are the digits from zero to nine. For the machines in your factory, even the number ten does not exist. Ten is really two numbers—the number of packs (1) and the number of bars (0). Similarly, 107 is three numbers, not one. It is the number of boxes (1), the number of packs (0), and the number of bars (7). Now, we all learn numbers this way in early elementary school (the ones, the tens, the hundreds, etc), but then we develop this pesky intuitive understanding that gets in the way. No adult thinks of ten as two numbers, but it really is.

So, in decimal numbering (i.e., the normal everyday numbers) we have ten possible digits (0-9), but in binary notation, we have two possible digits (0 and 1). Let's think of what that would mean for the chocolate factory. It would mean that two bars become a pack, two packs become a box, and two boxes a crate. Let's write this down because we will need it later:

crate, box, pack, bar.

So, what happens after ten bars have entered the binary chocolate factory? You have one crate, zero boxes, one pack, and zero bars. This does not sound intuitive at all, does it? How did I even figure that out? Let's meet halfway and use some decimal numbers to label the packaging hierarchy. Keeping in mind that each type of package contains two of the smaller type, then the total number of bars in each one corresponds to the following (decimal) numbers:

crate=8, box=4, pack=2, bar=1.

Now you can immediately see that 10=8+2; therefore, ten bars end up in one crate and one pack. If I were to write this down in binary notation, it would be 1010 (for one crate, zero boxes, one pack, and zero bars). But you might ask, "How is this useful?" If I have to think in decimal again to understand binary, why bother? The chocolate factory has the answer for you.

Imagine trying to build a machine that packages chocolate bars using the binary packaging scheme. What would that machine do? It would have temporary storage for exactly one item, and as soon as another one appeared, it would package them into the larger package type and put the new package onto the next conveyor belt. Pretty simple, huh? Now, imagine trying to build a packaging machine for the decimal scheme. How would you do that? How would you deal with the situation where a machine has six bars in its temporary storage, and another five appear?

The binary machine only has two states.

A) I have nothing in temporary storage, so I put the incoming object there.

B) I have one thing in temporary storage, so I package it with the incoming object and ship it to the next machine.

The decimal machine would have to have a state for all possible combinations of zero to nine objects in temporary storage and zero to nine objects incoming. A bit harder to build, no?

I cheated, though; I don't know if you saw it. I allowed five chocolate bars to appear simultaneously in the input of the decimal machine but only one at a time in the input of the binary machine. But what would it take to allow five bars in the binary machine? Well, five bars would be one box, zero packs, and one bar, so if someone unloads these things from a truck into the factory, this works just fine. The bar machine will handle the new bar, and the box machine will handle the new box using the two states we mentioned before. To see this with numbers, in binary notation, you would say:

110+101=1011

which is equivalent to the decimal notation:

6+5=11

You probably still think that 6+5 is immediately obvious, but 110+101 requires mental gymnastics, but this is only because you spent weeks in first grade memorizing that six plus five is eleven, and you've used it your whole life, so the answer comes automatically. In reality, though, if you had to build the packing machine, you would either have a very complicated machine with multiple internal states or only allow one bar at a time in the input. This is equivalent to someone asking you how much is six plus five and you responding, "Well, let me see, it's seven plus four, eight plus three, nine plus two, ten plus one, oh, it's eleven."

So, what's six plus five in binary? There is no such thing. Remember, back when we talked about decimal numbers, I said the decimal chocolate factory does not know the numbers 10 and 107 because a machine will never have to deal with 107 bars of chocolate? Similarly, in the binary factory, you never have six or five bars. Six plus five in the binary factory means that the factory contains one box and one pack, and in comes another box and a bar. So the factory will keep the bar in the temp of the first machine, the pack in the temp of the second machine, and the two boxes will be packaged into a crate by the third machine, so no boxes are left in it, and the crate will be pushed to the temp of the fourth machine. Do you see now why:

110+101=1011

It simply is:

0 crates, 1 box, 1 pack, 0 bars

+

0 crates, 1 box, 0 packs, 1 bar

=

1 crate, 0 boxes, 1 pack, 1 bar

What's there not to understand?

Fine, you might think, but what's with the chocolate packaging? And what does any of that have to do with computer science? Think about it this way. We have already seen how much easier it would be to build a packaging machine using binary instead of decimal. Consider now a computer. When it comes to binary, every digit can have only two states, zero and one. In terms of electrical circuits, this maps perfectly to the switch being off (no current flowing) or the switch being on (current flowing). This is easy to implement and easy to detect. How would you implement decimal? You would need ten different voltage levels and reliable ways to detect at which level the circuit is at each time, let alone the complicated combinations of states regarding how much current is already flowing and how much is coming in, just like with the chocolates. Implementing decimal math with circuits is practically impossible, but binary is obvious. It's just not intuitive to you because you think that 107 is one number and because you have memorized and used the addition table of decimal digits since elementary school.

With binary, all you have to remember is

0+0=0

0+1=1

1+1=0 plus 1 at the next digit up.

That's all. If you remember that and let go of your decimal intuition, binary notation will become much more approachable. You might even get a bar of chocolate ... or seven (111).

Damien Genet

Head of Cybersecurity Department, Senior engineer at SOLENT SAS Ex-ICL (UTK), Ex-inria

3mo

I provisioned 107 chocolate bars for nothing, only 11 were useful, you tricked me. Great article :)

Heike Jagode

Research Associate Professor at Innovative Computing Laboratory (ICL), University of Tennessee, Knoxville

4mo

I knew it---chocolate is the secret to life .. and binary .. and everything in between. It’s the ultimate 0 and 1! 🤩

To view or add a comment, sign in

More articles by Anthony Danalis

Insights from the community

Others also viewed

Explore topics