July 13, 2016

The Pun in Hex.Ink

There is one. Do you see it?

I'll give you a hint. It's the same pun the venerable Sir Terry Pratchett used when he named the Discworld's first thinking engine.

Any ideas?

I see you smirking at the back. You already know. I'm talking to everybody else. (All four of you.)

See, in addition to being a word for a magic spell, especially a malicious one, hex is also short for hexadecimal, which is a base 16 number system.

Hm. What's that mean?

Well, our usual number system is base ten, or decimal. Base ten means that it has ten digits that are used to count with, and then recycled in combinations to keep counting. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9... and then we recycle 1 and 0 with 10. Hex uses 16 digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, a, b, c, d, e, f... and then it recycles, again with 10, only now 10 stands for 17, or f + 1, just as in decimal, 10 stands for 9 + 1.

Oh, dear. I've definitely lost a few of you now.

OK, look. How we count is an invented thing. We, marvelous creatures that we are, invented it. Numbers don't exist without someone to count them. Math is a language we created to describe certain aspects of the world, and numbers are the characters we write that language in. It's all made up. It's also all real, mind you (I should really do a piece on that, actually, how math is like mythology), because it is an accurate language. But it's important to know that we made it up.

So the reason we count the way we do, from 0-10, is because just about everybody has ten fingers, physical and genetic accidents aside. There's nothing natural or absolute or even real about the way we count, it's just that we figured out counting with ten fingers.

Now, try to image for a moment how you'd count if you had, and had always had, eight fingers on each hand. Because that's what hex is. It's counting for sixteen-fingered aliens.

This becomes relevant because programmers encode a great deal of data in hexadecimal. Colors, for example. Much of what's sent between one computer and another through various internet protocols, too. It gets encoded in hex, because sixteen is a power of two, making it easily convertible to and from binary...

What's binary? Oops.

Binary is counting for aliens with only two fingers, ok? It's counting with only 0 and 1. It's how computers count. How computers do pretty much everything, actually, because they do everything by counting from 0 to 1, over and over and over.

Look, find me sometime in meatspace, and I'll teach you to count to 1023 on your fingers, in binary, and also the geekiest way ever to flip someone off.

So now I'm in school, setting out to study database design and administration, which is a kind of programming. I'll learn a few other kinds of programming, too. Which will make hexadecimal important and useful to me, and indeed I'll probably have to learn to do at least some math in it. And we've been talking in one of my classes about binary and learning a bit about it, and have sort of touched on hex, which we'll come back to later, and which I'll study in more depth in the spring.

So now hex has two meanings that are relevant to my life: one is programming math, and the other is magic. And they're both important to me.