Toolcedar

Why Do Programmers Use Hexadecimal?

Not because it is closer to how machines work — it is not. Hex survives because of one arithmetic coincidence that makes binary readable to humans.

· 2 min read

Computers do not use hexadecimal. They use binary, and they are entirely indifferent to how you write it down. Hex exists for people, and it survives for one reason: sixteen is two to the fourth, so exactly four binary digits fit into one hex digit, with nothing left over and no arithmetic required to see the boundary.

The conversion you can do by eye

Because the mapping is exact, converting between binary and hex is not really a calculation. You split the binary into groups of four from the right and replace each group with its digit. Nothing carries between groups, so changing one hex digit changes exactly four bits and no others. That locality is what makes hex readable in a way decimal never manages.

1111 1111  ->  FF     one byte, two digits
1010 0011  ->  A3
0000 1111  ->  0F

255 in decimal tells you nothing about which bits are set.

Why decimal is the awkward one here

Ten is not a power of two, so decimal digits do not align with bits at all. The decimal value 200 is 11001000 in binary, and there is no way to see one from the other without dividing. For anything where the individual bits carry meaning — flags, permissions, colour channels, memory addresses — decimal actively hides the structure you are trying to read.

A byte is two digits, always

Four bits is a nibble, and eight bits is a byte, so every byte is exactly two hex digits. This is why colour codes are six characters for three channels, why MAC addresses and hashes look the way they do, and why a hex dump lines up in neat columns. The format tells you the size of the thing at a glance, which decimal cannot do because its digit count varies with the value.

Hexadecimal is not closer to the machine. It is closer to binary, which is a different and much more useful property.

Where octal came from, and why it faded

Octal is base eight, so each digit maps to exactly three bits — the same trick, at a different size. It suited machines built around 12, 24 and 36-bit words, where three divides evenly. Once the industry settled on eight-bit bytes, four-bit grouping became the natural fit and hex won. Octal survives mainly in Unix file permissions, where three bits per digit happens to match read, write and execute exactly.

  • Base 16: one digit is four bits, one byte is two digits.
  • Base 8: one digit is three bits, which fits permission triples and little else today.
  • Base 10: no clean relationship to bits, which is why it is the wrong tool for bit-level work.

Reading the prefixes

A leading 0x means hexadecimal, 0b means binary and a bare leading zero traditionally means octal. That last convention is a genuine trap: in several languages 010 is eight rather than ten, which has produced real bugs in date handling where someone wrote a zero-padded month. Newer languages require an explicit 0o for exactly that reason.

Frequently asked questions

Why do hex colours have six digits?
Three channels of one byte each, and a byte is two hex digits. Red, green and blue take two digits apiece, which is why an eight-digit colour simply adds a fourth byte for the alpha channel.
Is hexadecimal faster for a computer?
No. The machine works in binary regardless and never sees your notation. Hex is purely a human-facing representation, converted at the point where a number is written or displayed.
What comes after base 16?
Base 32 and base 36 both exist, using more of the alphabet, and base 64 uses its own symbol set for encoding binary as text. Above base 36 there is no single agreed alphabet, so the digits have to be specified.