By aeiffert, 11/19/2018

You might've heard somewhere that computers only understand 1s and 0s. And believe it or not, this is true! Everything you've ever done on a computer, from writing homework with Microsoft Word to watching cat videos on YouTube, has been made up of quadrillions of 1s and 0s. But what exactly does this mean?

To get started, let's think about something for a minute. What do we think when we see the number "34?" Well, that's pretty simple, right? There's a 3 in the tens' place and a 4 in the ones' place, so we can actually write 34 as 3·10 + 4·1.

We can even go one step further by using exponents
and write 3·10^{1} + 4·10^{0}. Did you notice how the ones' place became 10^{0}?
This works with any number, no matter how large. With say, 95,201, we can do exactly
the same thing and get 9·10^{4} + 5·10^{3}
+ 2·10^{2} + 1·10^{0}.

That's great, but what does it have to do with computers? The 1s and 0s you may have heard about
in computer language are from a way of counting called **binary**. But before we go any
further, let's take another step back and consider something. Why do we only have 10
different number digits (0, 1, 2, 3, 4, 5, 6, 7, 8, 9)? What if an alien came to earth and had 16 different digits?
Surely, they wouldn't count to 9 and then start using a 1 and a 0 to say the number 10. Maybe they would
count up to 9 and then start using letters (...7, 8, 9, A, B, C, E, F, 10, 11...).

Or, what if a caveman suddenly appeared and only knew 2 of our 10 digits? Surely, that caveman would have a difficult time, right? It turns out, that he would be using binary, just like a computer. He would start with 0 and 1, just like us. But when he got to the number 2, he would run out of digits to express the 2 in the ones' place. Instead, he would write 10. Ten?! In our way of counting, yes! But in binary, 10 is actually two. 11 is three, 100 is four, 101 is five, 110 is six, 111 is seven, 1000 is eight, and so on. Do you see the trend? Instead of using more digits, we simply carry the one and keep on going.

If we think back to our early example with the number 34, which we wrote as 3·10^{1} + 4·10^{0},
we can now really start to see how binary works. Let's say we want to write 34 in binary instead of
base-10 (this is what our normal way of counting is called, where we use 10 digits––binary is also called base-2).
Where do we start?

If we think for a bit, we can see that what used to be the ones' place in base-10 is also the
ones' place in binary (1 in binary equals 1 in base-10). However, the tens' place in base-10 changes
when we use binary (10 in binary **does not** equal 10 in base 10––it equals 2 in base-10).

If we think even more, we'll see that we no longer have a tens' place in binary.
We have a **twos' place**! And even more than that,
we don't have a hundreds' place, we have a **fours' place**. Instead of every place being multiplied by ten,
it becomes multiplied by two.

Using exponents, this becomes 2^{2}...2^{1}...2^{0}. So how
to write 34? Well, let's see: 1·2^{5} + 0·2^{4} + 0·2^{3} + 0·2^{2}
+ 1·2^{1} + 0·2^{0} = 1·32 + 0·16 + 0·8 + 0·4 + 1·2 + 0·1 = 32 + 0 + 0 + 0 + 2 + 0 = 34.
So now we have a 1 in the thirty-twos' place and a 1 in the twos' place: 100010, and done. Easy, right?

So now you know what all those pesky 1s and 0s mean. Maybe you can try sending secret messages
to your friends (use numbers to stand for each letter, 0=A, 1=B, 10=C, 11=D, 100=E, 101=F, etc.).
But there's something even more. Remember our alien who had a whole 16 digits? It turns out,
this isn't as imaginary as it sounds. Computer scientists regularly use something
called **hexadecimal**, or base-16, which does indeed use digits 0-9 and letters A-F.

Can you imagine how this might work? 10 in base-16 is equal to 16 in base-10. 1B in base-16 is equal to 16 + 11 = 27! What about base-3? Or what about even base-0? (Base-0 took me a second to think about... hint: think tally marks)

Advertisement

Onions don't actually make people sad... When cut into, an onion releases a gas called "propanethiol s-oxide" that bugs our eyes.