Boneyard Tools

Understanding Hexadecimal and How It Maps to Bytes

Why programmers write numbers in base 16, how each hex digit maps to four bits, and what the 0x prefix and letter case actually mean.

Why base 16 instead of base 10

Computers store everything as bits, groups of ones and zeros, and a single byte holds eight of them. Writing a byte in decimal, like 205, hides the underlying bit pattern, while writing it in binary, like 11001101, is accurate but long and easy to miscount. Hexadecimal sits in the sweet spot: base 16 lines up perfectly with binary because 16 is 2 to the fourth power. That neat relationship is the whole reason programmers reach for hex when they need to see the bytes.

One hex digit is four bits

Each hexadecimal digit stands for exactly four bits, a group often called a nibble. The digits 0 through 9 cover the values zero to nine, and the letters a through f cover ten to fifteen, so a single digit spans every combination of four bits. Because two nibbles make a byte, any byte is exactly two hex digits, which is why the value 255 becomes ff and 205 becomes cd. This clean two-digits-per-byte mapping makes hex the natural way to read memory dumps and color codes.

Reading the 0x prefix and letter case

When a number could be decimal or hex, a prefix removes the ambiguity. Many languages use 0x, so 0x10 is sixteen while a plain 10 is ten, and CSS uses a leading hash for colors like #ff8800. The prefix is only a label and carries no numeric value of its own, so turning it off here leaves the same digits. Letter case is likewise cosmetic: ff and FF are identical values, and the uppercase toggle only changes how the letters look, never what they mean.

Converting by hand to check the tool

To convert a decimal number yourself, divide by 16 repeatedly and keep the remainders. For 255, dividing by 16 gives 15 with a remainder of 15; dividing 15 by 16 gives 0 with a remainder of 15. Each remainder of 15 is the digit f, and reading them from the last division to the first spells ff. Larger numbers just take more steps, and because this converter uses arbitrary-precision arithmetic it stays exact even when the number is far too big to do quickly on paper.

Frequently asked questions

Why do some hex values use letters?

Base 16 needs sixteen distinct digits, but decimal only supplies ten. The letters a through f fill in the values ten to fifteen so every four-bit group has a single symbol.

How do I go from hex back to decimal?

Multiply each digit by 16 raised to its position from the right and add the results, or just paste the value into the hex to decimal tool to do it instantly.