Binary to Hexadecimal: How the Conversion Actually Works

Hexadecimal looks like a completely different number system from binary, but the two are actually closely related — so closely that converting between them doesn’t require any decimal math at all, just a grouping trick.

crossorigin="anonymous">

Why Hex and Binary Pair So Naturally

Hexadecimal uses 16 symbols (0 through 9, then A through F) instead of binary’s 2, and 16 happens to be exactly 2 to the 4th power. That relationship means every single hex digit corresponds exactly to a group of 4 binary digits, with no rounding or approximation needed in either direction.

Converting Binary to Hex, Step by Step

Starting from the rightmost digit, split the binary number into groups of 4 digits, padding the leftmost group with extra 0s if it’s short. Convert each 4-digit group to its decimal value, then convert each of those decimal values to its matching hex symbol (10 through 15 become A through F).

A Worked Example

Converting 11010110 to hex: split into two groups of 4, giving 1101 and 0110. 1101 converts to 13 in decimal, which is D in hex. 0110 converts to 6 in decimal, which stays 6 in hex. Combining both groups gives D6 as the final hexadecimal value.

A Second Example Going the Other Way

Converting the hex value 2F back to binary: 2 becomes 0010, and F (15) becomes 1111, giving 00101111 when the two groups are combined — the same grouping trick working in reverse, digit by digit.

Where This Comes Up in Practice

Hex-binary conversion shows up constantly in web development (color codes like #FF5733 are hexadecimal), computer memory addresses, and low-level programming, precisely because hex is compact while still translating to binary with zero ambiguity, unlike decimal, which doesn’t divide evenly into binary groups.

The 16 Groups to Memorize

  • 0000 = 0
  • 0001 = 1
  • 0010 = 2
  • 0011 = 3
  • 0100 = 4
  • 0101 = 5
  • 0110 = 6
  • 0111 = 7
  • 1000 = 8
  • 1001 = 9
  • 1010 = A
  • 1011 = B
  • 1100 = C
  • 1101 = D
  • 1110 = E
  • 1111 = F

Know these and you can convert any binary number to hex by sight.

More Examples

  • 10111100 splits into 1011 1100, which is B and C, so BC (188 in decimal).
  • 11111111 splits into 1111 1111, so FF (255).
  • 001110100101 splits into 0011 1010 0101, so 3A5.

Hex to Binary Examples

The hex value 7E becomes 0111 and 1110, giving 01111110. The value A5 becomes 10100101, and 09 becomes 00001001.

Reading a Web Color

A color code such as #FF5733 is three bytes in hex: FF for red, 57 for green and 33 for blue. In decimal, that is 255, 87 and 51, so the color has full red, a moderate amount of green and a little blue, which gives an orange-red shade.

Why Programmers Prefer Hex

A byte is 8 binary digits but only 2 hex digits. A 32-bit value is 32 binary digits but only 8 hex digits. Hex keeps long values compact and readable, and every digit lines up with four bits, so nothing is lost.

Common Mistakes

  • Grouping from the left instead of the right when the digit count is not a multiple of four.
  • Forgetting to pad the leftmost group with zeros.
  • Mixing up B (11) and 8 when reading handwritten values.

See also hexadecimal explained for where hex is used in practice.

Convert Your Own Values

Working through the grouping method by hand a few times makes it click quickly, since there’s no decimal math involved at any step. Our hex converter and binary translator both handle these conversions instantly, and our guide on hex subtraction covers the next step once you’re comfortable converting between the two systems.

Leave a Comment