Next in our ongoing series of articles about computers, we talk a little about why computers think differently than we do. You might imagine that the thoughts of the creator would be reflected in the creation, but then again M.D. Frankenstein had a similar problem. Computers are a little better with their numbers than we are. Numbers describe their world just like language describes ours. It's how we build them, down to their very heartbeat. We do that by teaching them how to speak binary.
Binary does everything in sets of two—that's why it's all 1s and 0s. Here's the binary numeral for the number "six" as a sample: "110." The system we humans usually use is the decimal system, counting everything in sets of ten. Here's the decimal numeral for the number "one hundred" as a sample: "100."
Both can do all the same stuff, but computers lean toward binary because it reflects the confines of the hardware: presence or absence of electrical signals, positive or negative polarity on magnetic drives, true or false values in logic circuits.
Okay, that last one's more programming than hardware but let's not deep sea dive when we should be snorkeling.
It's a 0 and a 1.
This article is going to talk a lot about numbers, so it's important for us to all be on the same page when we use vague words to discuss specific mathematical concepts. Things will be clearer if you can think like a computer, and know for sure when "yes" means "yes" and "no" means "no." Below we fired some bullets:
It's hard to pin these things down and label them properly. So permit us a brief demonstration.
Imagine the number "five thousand" (ah, see, you're already picturing the numeral in your head). The written English word for this value is the above name, "five thousand." The numeral shorthand is "5000." It's shorter than "five thousand" because it uses fewer, shall we say, keystrokes to write it. These keystrokes are characters. Each character fills a digit slot in the numeral. In this case, there's four of them: one each for the "thousands" (5), "hundreds" (0), "tens" (0), and "ones" (0) places.
Fill each applicable digit with a character, and you get a numeral. That numeral represents a number. Hopefully that explains it more clearly than stirring a mud puddle with a stick.
A couple of footnotes that are especially important to this article's topic.
First, in any number system, the number of available characters equals the number the system is based on. As we will discuss below, for a "base 10" system, that means there are ten base characters (oddly enough, it's not 1–10; it's 0–9). Those characters are the options available to choose from when building a numeral. The decimal system has ten characters; the binary system has two.
Second, each digit position increases the value of the number the numeral represents by a factor of the base (we weren't math majors, we swear). In other words, in the decimal system for instance, adding a digit to "1" to make it "10" increases its number value to ten times what it was. Each digit adds another "times ten" to the value, as it increases the possible numbers in that range to ten times what it was.
There. Now you have some ground work to build on. And don't come complaining to us that you graduated from high school or college just so you wouldn't have to take another math class. You were the brave soul who chose to journey through the TL;DR version. That's pretty much like signing a waiver.
We've been raised in a "base 10" society. You may be thinking, "How is our number system based on 10? I thought it was just based on numbers." Well, yes, but we picked a numeral and made it special. That numeral was 10. How did we make 10 special? We gave it a crown and said, "All other numerals shall bow down to thee." Don't believe us? We'll prove it.
Think of the biggest
number numeral you can. It was a 1 with a long line of 0s behind it, wasn't it? You didn't think of, say, a long string of 5's, or even a long string of 9's, did you? That's because they feel incomplete. We feel like 5 is only halfway to the biggest number possible, and that 9 is still one short. That's because our number system is based on 10.
What's the full amount of something? 100%. What's one half plus one half? 1. What's the start of every new number category (tens, hundreds, thousands, etc.)? It's 1, with the appropriate number of 0's behind it. Even when we want to amplify or exaggerate something, we use similar conventions. Things like, "I must have done that a million times," "They've spent hundreds of hours on it," "There were a thousand firemen there last night."
That last one would be an egregious misapplication of resources.
Why is all of this important? Because in order to fully understand the base concept behind binary numerals, you have to denaturalize the decimal system—separating yourself from the idea that counting by tens is the only way things can be done. Binary works in a fundamentally different way, and wrapping your brain around it requires understanding how we normally count so you can identify the differences.
In the decimal (base 10) number system, each digit can be any of ten possible characters. The characters—which are "0" through "9"—are combined to represent every number from here to infinity. Ten characters, ten options. That's it. Then, each time you add a digit (1, 10, 100, 1000), you increase the value of the numeral by a factor of ten, because you open to another level of ten-fold possibilities.
Why do we use this system, specifically? It may have something to do with the number of digits (pun intended) we have on our hands and feet. Beyond reasons like that, it's largely a matter of preference. It's not inherently more efficient than systems based on other numbers. In fact, some mathematicians have postulated that numbers like 12 would serve us better, since they're divisible by more numbers than 10 is. Generally though, we lesser mortals don't notice things like that. We think, "Ten fingers, ten numbers; sounds good," and that's that.
We're human, and we don't always conduct our business in a world of specifics, because sometimes there's just not a yes/no response to the issue at hand. That's why it's kinda handy to use a number system with more than two possible characters—it leaves room for approximation.
Computers, as you might have guessed it, live in that world of specificity. Only with a great deal of effort do those yes/no responses approximate the flexibility of human reality. That's because, at their core, computers are just a long string of answers to yes/no questions. Let's dig down to bedrock to understand why.
Computers use electricity. No, they wallow in it. They don't just run on electricity. They use electricity to do everything. They process input and reply with output using electricity. They communicate to other computers using electricity. They translate audio and video signals using, you guessed it, the zappy stuff from Thor's hammer. Electricity is, all at once, their power source, the carrier medium for their internal thought and processing, and the go-between language they use to communicate with the world.
Imagine if your blood, neurons, eyes, ears, and voice were all the same thing (eww). That's what electricity is like to computers.
How does all this apply to binary? The simplest binary question a computer asks itself is this: "Is there an electrical current?" There are only two possible answers to this question: either "yes" or "no." That's it. One question, two possibilities. Not ten. Or twelve. Or fifty-five. Two. There's no "almost," "maybe," "kinda," or "I think so." It's either "yes" or "no."
There are other kinds of questions a computer asks itself, but they all follow this basic format: open/closed circuit, high/low voltage, positive/negative polarity (magnetic storage drives), true/false (statements in programming code). This either/or nature that computers demonstrate necessitated a mathematical system that was easier for them to digest. So someone really smart decided, "If computers think in twos, why not let them count in twos?" So we gave them a system that allows them to do just that.
As opposed to the decimal system's ten characters (0–9), binary only has two: 0 and 1. Each digit in a binary number is either 1 or 0, indicating either the presence or absence of the value in the sum of the number. And since that's already how small a computer would break it down, it means that every piece is already
byte bite-sized for the computer.
In decimal, numerals increase in number value by powers of ten each time a digit is added. So 10 is 10 times bigger than 1, as is 100 to 10, and 1000 to 100, etc., all the way till you decide you want to stop counting.
Binary is a base 2 system. That means that every time you add a digit (1, 10, 100, 1000), the value doubles instead of magnifying by powers of ten. In the decimal (base ten) system for example, 100 = one hundred. In binary (base two), 100 = four. And since there's only two options, the "0" means there's no value, and the "1" means the value at that digit applies. Below is a delightful chart that illustrates it with a little clarity.
At this point you may be wondering "That's all fine and dandy, but how do you get the numbers in between?" It's simpler than you think. Just like the decimal system, representing a value is merely a matter of mixing and matching the mathematical markers. To demonstrate, let's do what all the cool kids are doing, and count to ten:
You can count any number in binary, same as the decimal system. It just requires more digits to do so than you're used to. And since computers are better with numbers and numerals than we are, keeping track of all the 1s and 0s only gets complicated when the size or quantity starts to exceed memory capacity.
So up till now, weve been talking about decimal and binary as if they're the only two options (how ironic). But there's at least one more option: "hexadecimal." (We're treading very lightly here. Mind the rabbit hole.)
Hexadecimal is a base 16 system that uses the characters 0–9 and the letters A–F. Why the letters, you ask? Because mathematicians and programmers like watching you scratch your head till it's bald. All joking aside, the reason for the letters is to stand in place of symbols we haven't invented—namely, unique characters that represent the numbers 10–15. Much of the above hooplah applies, like how you can use it to count any number. But the question you're probably wanting to ask is: why use it?
A couple of reasons, and they've largely been discussed here already. See, decimal has one advantage over binary, and that is that it can represent larger numbers with fewer digits and smaller numerals. Need enough phone numbers for everyone to get their own? Start with a four-digit base; that gives you 10,000 possibilities: 0000 through 9999. Need more? Add a prefix. With 1,000 possible prefixes, and 10,000 possible base digits per prefix, you have ten million possible phone numbers, and you haven't even added area codes or country codes yet. That's all from adding a measly three digits.
Binary...well, binary struggles with that a bit. It's possible, but it takes a little bit more effort. And digits.
Binary Number: 0100110001001011010000000
Total Value: Ten Million (10,000,000 in decimal)
So bumping up to a higher base system has perks. In fact, the internet is dealing with this very problem right now, switching steadily from binary IP addresses to hexadecimal ones to afford for some breathing room. But why 16? Why not 12, or 13, or 37?
Because 16 is on the binary progression.
Because hexadecimal's smallest units are essentially two bytes put together, it makes it really easy to convert hexadecimal to binary, and back again. Decimal doesn't convert well to either, but then again we picked an awkward number to begin with, so that's on us.
The point is, hexadecimal is out there, and it's doing its thing. Computers are using it more and more frequently, but it functionally serves as the body on the binary chassis of the car. As for decimal, it's probably the dog that sticks its head out the window while going down the freeway.
Why use binary over the decimal system? Because binary just makes sense to computers. It's how they relate to the world. It's the sounds that form their words, and the words that communicate their ideas. Or at least the data that carry our ideas. It's a convenient way to program them, and it's convenient to maintain them in that state. And honestly, why not use binary? It's really just too cool to pass up.
As always, feel free to call in to our tech-savvy, friendly, former trapeze artist support crew. They'd be more than happy to answer any additional questions you might have, and beyond that, they're flippin' fast.