Sitemap

The hexadecimal to binary correspondence

2 min readAug 17, 2026

--

Press enter or click to view image in full size
Photo by Umberto on Unsplash

I was watching a video from one of those YouTubers who post videos about computer programming. With his extensive experience programming in C and C++, it’s not surprising that long ago he picked up that one hexadecimal (base 16) digit neatly corresponds to four bits (base 2).

We see that 0 is 0000, 1 is 0001, 2 is 0010, 3 is 0011, and so on and so forth to E is 1110 and F is 1111.

Get Alonso Del Arte’s stories in your inbox

Join Medium for free to get updates from this writer.

It’s something that he and I have taken for granted, even though my experience in Java means that I just don’t deal with binary arithmetic as much as someone like that YouTuber programming closer to “the bare metal.”

Nevertheless, I think every programmer should be aware of this correspondence between binary and hexadecimal, even the ones who think they will always have A.I. to take care of boring details such as the appropriate bit shift to get a flag from a register. It’s good to have a number sense in this field.

The vast majority of computers operate in binary. But for people, it is tiresome and error-prone to type numbers bit by bit. Many compilers, such as the ones for C++ and Java, provide a way for programmers to write numbers in hexadecimal.

It is much easier, for example, to type the hexadecimal number 8A9B than 1000101010011011. The exact syntax depends on the programming language.

Compilers often also understand octal (base 8) numeric literals, but these are not as convenient for programming because an octal digit corresponds to three bits whereas one hexadecimal digit corresponds to four bits, half of a byte.

--

--

Alonso Del Arte
Alonso Del Arte

Written by Alonso Del Arte

is a Java and Scala developer from Detroit, Michigan. AWS Cloud Practitioner Foundational certified