[ELI5] Why isn’t hexadecimal used for creating computer storage data? Why is it always in binary?

799 views

I’m asking this because data in game cartridges always seem to be shown in hexadecimal values instead of binary. I reckon maybe hexadecimal is more convenient than binary.

In: Technology

10 Answers

Anonymous 0 Comments

TLDR; hex is a lie that we use to make binary wieldly. Binary is a lie we use to make the hardware almost wieldly.

# Binary is a lie.

For computers, “binary” doesn’t even really exist at the lowest level – it’s either “lots of power” (on) or “hardly any power” (off). The reason we have the concept of binary is because we do some funny things to make more than one power flow matter at a time. To facilitate this, we get multiple wires caring power at a time. Most machines currently run 64 wires as a single unit. (Technically called a “word”, but moving on).

Now, you asked explicitly about data storage. The truth is that the same concept applies. The hardware is set to either emit a high or low power signal when power is run through it. That’s it. That’s all it knows. (I’ll get to why you see the hexadecimal addresses in a bit)

Now, this kinda gets messy if you want to do a deep hardware dive. For now, I’ll just mention logic gates, which allow you to determine the output of one line based on two inputs. Typically your gates are And, Or, Not (single input, but worth mentioning), Nand, XOR, and XNor. They pretty much do what they look like, with N meaning the output is flipped and X meaning it only outputs if one of the two meets the conditions, not if both do.

# Correction: Binary is a very useful lie.

Now, most of us software people don’t actually want to think about it like wires. The physical wheres and hows are things that we don’t really want to work with, but on a low level, we still need them. We handle this by encoding all that hardware nonsense in binary. Binary can be written left to right, so it’s easier to hand write logic before you attempt an implementation. You can easily isolate values from meaning, or add spacing to separate segments of it, making it easier to work with for larger projects, like encoding things! It’s not *exactly* a number, but we can get it to act like one! We can ADD with it! We can even assign meaning to groups or individual bits, allowing us to, say, build instructions like “[11010101] 11001100, 00110011”. (I didn’t actually make this an instruction, sorry.)

# What about Hex?

Well… it turns out binary is a pain too. While it is better than trying to imagine all the hardware, It’s messy. Humans aren’t good with long strings of similar numbers. A small mistake can be difficult to catch – imagine trying to find the difference between 11101001101110010010101101100110 and 11101001110110010010101101100110. Looks like a pain, right?

So, we transform it. At this level, we don’t want to go particularly far from what the computer understands, but we need something that’s easier for us. So, we directly encode the bits. 4 bits works out well with our normal number system if we tack on a few letters, and it fits well with addressing so we use that. Encoding one of our earlier numbers:

|1110|1001|1011 |1001 |0010|1011 |0110 |0110 |
|:-|:-|:-|:-|:-|:-|:-|:-|
|E|9|B|9|2|B|6|6|

we get E9B92B66. Now, compare that to E9D92B66. I bet you found the difference almost immediately. It takes up much less visual space. So much easier to work with! Every two letters is a byte, Eight of those makes up 32 bits, the old standard for a word. Sixteen make up 64 bits, which is current standard.

Conveniently, and as it will be for always and forever, every single one of those numbers is an easy multiple of four. (It’s a thing about addressing bits. Because of the way binary works, there’s very little incentive to explicitly force a change.)

So… we display it as hex.

Because we like it more.

You are viewing 1 out of 10 answers, click here to view all answers.