What is Binary?
You use Binary every day without even knowing. Every time you type on your keyboard. Every time you send a text message. Every time you turn a light switch on or off. Binary is all around us... it’s up to us to spot it.
My operator explained the rest with tables. I’d rather let you handle the goods.
Lesson 1, written zero zero one. A bit is a one or a zero
A bit is one binary digit, a one or a zero. Flip mine to give me a yes or a no.
One bit
| bit = 0 | bit = 1 | |
|---|---|---|
| Not used | Used | |
| Closed | Open | |
| False | True | |
| Off | On | |
| No | Yes |
A bit means nothing until somebody decides what its two states stand for, and any pair of opposites will do. Are you seeing a pattern? Every pair on the list is a system of two. No more. No less. Binary is the name for exactly such a system, and everything I carry is made of it.
Do mind the zero. The list calls it not used, but a zero is half the system and holds its place as firmly as a one, as you’ll see two lessons from now.
You may have noticed the lessons are numbered the way I count. By the third, you’ll be reading the numbers yourself.
Lesson 2, written zero one zero. Eight bits make a byte
A single bit can only say two things, which makes for rather dull conversation. Line up eight of them and you have a byte, and a byte has 256 patterns to choose from. They come in a strict order, and the quickest way to learn it is to count. Count to three. Then, before you press +1 again, have a guess at which bits will flip.
One byte, counting
Three of them flipped, where every count before it flipped one or two. At three, the two bits on the right were both 1 with nowhere left to go, so they dropped back to 0 and handed a 1 to their neighbor. Press −1 and the neighbor pays it straight back. The odometer in my operator’s car does the same when 99 turns over to 100, with ten digits to a wheel. A byte makes do with two.
Are you reading from right to left? The last bit flips on every count, its neighbor half as often, and the next one half as often again.
Lesson 3, written zero one one. Base 2 mathematics
The pattern is no coincidence. Start on the right with 1, and each place to the left doubles: 2, 4, 8 and on up to 128. Mathematicians call it Base 2 and write the values as powers of two, which I’ve noted above each one for the curious. A bit set to 1 means its value is used. Add up the values in use and you have the number the byte is holding.
What each bit adds
Select the bits whose values add up to 5.
Turn all eight on and you have 255. Count the zero as well and there are your 256 patterns. You may also care to look back at the lesson numbers, which should now read as one through three.
Lesson 4, written one zero zero. Great, but what does any of this have to do with words?
Here is where I come in. Long before my time, a committee settled which number goes with which character and called the arrangement ASCII, and computers have honored it ever since. In my ledger, the capitals run in order from A at 65.
One byte, one character
I’ve put up a capital A. Flip the bit marked 32. What do you suppose I’m carrying now?
Put another 32 on the bill and I’ll carry a little a for 97. One bit is the whole difference between an ASCII capital and its lower case, which rather takes the mystery out of the Shift key. Every letter in the picker plays the same trick.
A word of caution before we go on. Under Digits, the character 1 is not the number 1. It is a mark on a key like any other, and I carry it as 49. Type the number 10 and you’ve sent two characters, and so two bytes.
Lesson 5, written one zero one. Wrapping up
A message is nothing more than bytes in a row, one or more for every character. I pack my words in UTF-8, which keeps every ASCII number as it is and spends extra bytes on everything else. The e in cafe travels in one. Try café. I charge by the byte, so do check my figures.
| Character | Byte | Decimal |
|---|
And there you have my entire trade, one byte to a line. At the front of the operation, under Binary, I do the same at rather greater speed, in either direction, and in six other formats besides.
My operator closed his primer by promising a second article, in which the Smuggler would dive deeper into Binary. Fourteen years on, he assures me it is coming along nicely.
Before you go, there is one last delivery at the foot of the page. Work out its first letter by hand and you may consider yourself a graduate. The rest of the note is for the curious, and decoder rings are permitted.
Until next time...
All the best,
The Word Smuggler