Zeroes and Ones are the building blocks of what’s known as binary, and the juice that our digital world runs on. Another way to think of it is this. In our so-called Base 10 world, we deal with ten digits, and depending upon what you’re counting, you can either go from 0 to 9 (things) or 1 to (1)0 (dates, place order). Since 9 is the highest digit, when any column hits it, the 9 next rolls back to 0 and the digit to its left increments up, initially from 1.
So after the number 9, we get 10. After 19, we get 20, after 99, it’s 100, and so on. Also note that 100 happens to be 10 x 10, 1,000 is 10 x 100, 10,000 is 100 x 100, etc. This will be important in a moment.
In the binary world, things roll over faster. In fact, the only digits you have are 0 and 1, so counting works like this: start with 0, then 1. But 1 is as high as we can go, so after 1 comes 10, which, in binary, represents 2.
That might seem strange, but here’s the logic behind it, going back to 10. What is 10, anyway? Well, it’s the number that comes after we’ve run out of digits. Since we’re used to base 10, it doesn’t require any explanation to see that 10 always comes after 9. At least in base 10. I’ll get to that in a moment, but first there’s a very important concept to introduce, and that’s called “powers.”
The powers that be
No, I’m not talking Austin Powers. Rather, raising a number to a power just means multiplying the number by itself that many times. In its basic form, you’ll often see Xn. That’s what this means. It’s just a more efficient way of writing things out:
2 x 2 = 22 = 4
3 x 3 x 3 = 33 = 3 x 9 = 27
10 x 10 x 10 x 10 x 10 = 105 = 100 x 100 x 10 = 10,000 x 10 = 100,000
Here’s an interesting thing about powers of 10, though. The end result will always have exactly as many zeros as the exponent, or power that you raised 10 to. 109. Simple: 1,000,000,000. If it’s 102, 100, and so on.
And the two fun sort of exceptions that aren’t exceptions to keep in mind:
X x 0 x N = N, aka X0 = 1
X x 1 = X1 = X.
101 is 10 with 1 zero, or 10; 100 is 10 with no zeroes, or 1.
In other words, any number to the power of zero equals 1, and any number to the power of 1 equals itself. And there you go, that’s all you need except for this: When it comes to determining what the power is, we count “backwards” from right to left. The last digit before the decimal takes the 0 power, next to the left is 1, next over from that is 2, and so on.
Everything in its place
Since places correspond to powers, in Base 10 we would call the digits, right to left, the ones, tens, hundreds, thousands, ten-thousands, hundred-thousands, and so on places. In binary, you’d have the ones, twos, fours, eights, sixteens, thirty-twos, etc.
Makes sense? Then let’s look at a four-digit number in binary: 1776.
But here’s an interesting trick: in computer logic, it often becomes much easier for the circuits to literally read in the digits backwards in order to do these steps upwards in the proper order. This saves the step of having to figure out how long a string is before assigning the proper power to the most significant digit, which is the last one on the left.
So, to calculate, we’ll count it from right to left, which will make it easier to follow what’s happening. Let’s go with 6771 for ease of use. The 6 is in the zero position, so it represents 6 x 100, in which case this is 6 x 1, meaning just plain old 6.
Next, a 7 times 101, which is just 10, so this spot is worth 70 and we’re up to 76.
Next, 7 times 102, which is 100 times 7. Add that to the rest, it’s now 776.
Finally, a 1 in the spot multiplied by 103, which is 10 x 10 x 10, which is 10 x 100, so… 1,000. Slap that on the rest, and there you go: 1776.
This works exactly the same way in any other base. So let’s look at a typical binary number: 1011 1110. As humans, we could deal with doing the whole thing backwards, but again, let’s make it easy for the machine, feed it in right to left, and watch the sequence in action:
Digit (D) 0 1 1 1 1 1 0 1 Power (p) 0 1 2 3 4 5 6 7 2^p 1 2 4 8 16 32 64 128 2^p x D 0 2 4 8 16 32 0 128 SUM 0 2 6 14 30 62 62 190
Or in base three or trinary, let’s look at 21221121, entered again in reverse:
Digit (D) 1 2 1 1 2 2 1 2 Power (p) 0 1 2 3 4 5 6 7 3^p 1 3 9 27 81 243 729 2187 3^p x D 1 6 9 27 162 486 729 4374 SUM 1 7 16 43 205 691 1420 5794
Now, let’s take a look at an interesting property in Base 10 and see if it translates over.
Dressed to the nines
In Base 10, any number divisible by nine also has all of its digits add up to nine. You can easily see this with the first few pairs of two-digit multiples of nine: 18, 27, 36, 45, 54, and so on. The tens digit goes up by one while the ones digit goes down by one, and that makes perfect sense. Why? Because when you add nine, what you’re really doing is the same as adding 10 and then taking away one.
It doesn’t matter how big the number is. If you can add the digits up to nine, then you can say it’s divisible by nine. To just pull a number out of thin air, I guarantee that 83,764,251 is evenly divisible by nine. I could also put any number of nines anywhere in that number and it would still be divisible, or put the digits in any order. And if you have a number that has all of the digits from 0 to 9 in any order, then it’s divisible by 9.
So does this property hold for other bases? What about Base 8? In that case, we should expect seven to be the magic number. I’ll spare you the torturing of Excel I did to run a test, but the answer is: Yes. If a number is divisible by seven in Base 8, then its digits add up to seven. Here’s the list from the Base 8 equivalent of 1 to 99 (which is 1 to 77): 7, 16, 25, 34, 43, 52, 61, 70. Now none of those numbers in Base 10 is divisible by seven, but in Base 8 they are. Here’s how and why it works.
When you divide a number in Base 10 by 9, you start on the left, figure out how many times 9 goes into that whole number, carry the remainder to the next digit, and repeat the process. So to divide 27 by 9, you start by dividing 20 by 9. This gives you 2 times 9 = 18. Subtract 18 from 20, you get 2. Carry that over to the next place, which is 7, add 2 and 7, you get 9, which is divisible by 9. Add the 2 from the first result to 1, and your answer is 3.
Did you notice anything interesting there? It’s that you happened to wind up with the number in the Base digit twice. Two times 9, with the remainder of 2 adding to the other digit, and what was the other thing we noticed? That’s right. The sum of the digits is 9, so what’s left when you divide the ten’s digit by 9 has to add to the one’s digit to total 9.
This is true in any other base. Let’s look at our Base 8 example of 34. We can’t cheat by converting to Base 10, so the 3 tells us that 7 goes into the number three times. But since 3 times 7 is 3 less than 3 times 8, that’s our remainder. Add that to the 4 to get 7, and boom, done. In Base 8 34/7 = 3+1 = 4. Convert the Base 8 to Base 10 to get 28, and voila… 4 times 7 is 28. The answer is the same either way when you reduce it to a single digit.
A spot check bears this out with other bases, so it would seem to be a rule (though I’m not sure how to write the formula) that for any Base, B, and any number evenly divisible by B-1, the digits of that number will add up to B-1.
That’s the funny thing about whole numbers and integers. They have periodicity. What they do is predictable. Multiples of any integer will appear at regular intervals without jumping around no matter how far towards any particular ∞ you go. Irrational numbers and primes, not so much. But it’s good to know that the basis of digital computing is so reliable and regular. In fact, here’s a funny thing about binary: Every single number in binary is evenly divisible by 1 because all of the digits of every single number in it adds up to a number divisible by… 1. And a Base 1 numbering system is impossible, because the largest possible number in it is 0. It also breaks the whole Base rule above, because nothing can be divided by 0. Base 1 is the Black Hole of the numbering system. The rest should be pretty transparent.