Can’t Code #2: Binary Basics
March 25th, 2014 by
The most basic code in the world of digital technology is binary code, which employs the binary digit, or “bit” for short. This code consists of 1’s and 0’s. The 1 means that something is; the 0 means that something isn’t. There’s no room for ambiguity when using bits. We’ll explore just how computers process binary information to create a meaningful user experience in the next installment of this blog series, but in the present post, I’d like to first discuss how binary digits operate, and what it means to count in binary.
There’s Nothing Special About the Number 10
The number system that we commonly use today, the one that consists of 1’s and 2’s and 8’s and 9’s, came to us from India a very long time ago. It supplanted the more cumbersome Roman Numeral system of X’s, V’s, and M’s. The most important characteristic of this “Hindu-Arabic” number system, and the feature that ensured its primacy over Roman numerals, was its most lowly number: zero.
Zero revolutionized counting by providing a placeholder for intervals of 10. When you count past 9, the 9 becomes a 0, the integer to the left becomes a 1, and you’ve got 10. Ten 10’s become 100, ten 100’s become 1000, etc. Ten, as a numeric concept, suggests completeness; a closed circle; the beginning of a new cycle. But in order to understand binary, it’s first necessary to understand that, despite all this, there’s nothing inherently special about the number 10.
The Counting System
We have adopted a “base-10” or “decimal” counting system for the simple reason that our species has 10 fingers. The Hindu-Arabic system, and it’s trademark number 0, allows us to essentially count sets of fingers with ease. 10 is one set of fingers. 20 is two sets of fingers. If we had 8 fingers, the way we count would be very different. We’d be using a “base-8” or “octal,” rather than a decimal, counting system. 10, however, would still represent one set of fingers.
To illustrate this, let’s visualize the following scenario: E.T., the titular character from the 1982 Steven Spielberg film, is trying to count 20 penguins in a row. Let’s briefly evaluate E.T.’s anatomy: he’s got tiny little legs, which leaves him very low to the ground, a long neck, long arms, and most importantly, 4 fingers on each hand, 8 fingers total. And with those 8 fingers, he begins to count 20 penguins. Let’s listen as he counts:
1, 2, 3, 4, 5, 6, 7, 10 little penguins!
11, 12, 13, 14, 15, 16, 17, 20 little penguins!
21, 22, 23, 24 little penguins all in a row!
Do you see why E.T. counted 24 penguins whereas we, with our 10 terrestrial fingers, would have counted 20 penguins? The number 10, as we have established, is a symbol used to represent one set of fingers, no matter how many fingers are in the set; and 20 is used to represent two sets of fingers, no matter how many are in the set. While we would have counted the row of penguins on just two sets of our ten terrestrial fingers, E.T. required two and a half sets of his eight alien fingers. The reason that his above counting scheme might look odd to us is that he had no use for integers “8” and “9,” and therefore his count is “missing” four numbers that would be included in our own: 8, 9, 18, and 19.
Counting Penguins With Just Two Fingers
Here’s how this relates to computers: computers only have two fingers. The “binary” code that serves as the language of computers is a base-2 system, and thus only utilizes two integers: 0 and 1. It doesn’t involve integers 2 through 9. By the time your computer has counted to 2, it’s reached 10; much like by the time E.T. has counted to 8, he’s reached 10. Imagine a person with two fingers counting a line of 10 penguins in the same way that E.T. used his 8 fingers to count 20 penguins. It would look like this:
1, 10, 11, 100, 101 little penguins!
111, 1000, 1001, 1010, 1011 little penguins all in a row!
This hypothetical two-fingered person would never get to twenty, or thirty, or forty, because she wouldn’t even know what “2,” “3,” or “4” were. The only numbers that would exist between 0 and 100 in her mind would be 1, 10, and 11. Any other numbers would involve integers higher than 1, and therefore would not be counted.
Using binary might be a really awkward way of counting penguins, but as it turns out, it’s a pretty effective way of transmitting information over vast distances. In the next installment of Can’t Code, we’ll take a look at how computers use these binary numbers to create useful information and media. In the meantime, here’s a decimal to binary converter to play around with in order to reinforce your understanding of the ever-lovin’ bit!