How to convert Octal and Hexadecimal to Binary?

Adam Turner
8 min readOct 30, 2021

--

In a previous article, I wrote on the subject of converting binary to decimal and decimal to binary, covering initially what place value and the number bases refer to, giving you a solid base to understand how to compute these conversions.

If you do not yet understand those number bases (Base 2 and Base 10), please refer back to that article first.

In this article, I will be covering the Octal (Base 8) and Hexadecimal (Base 16) number systems.

I will discuss what the Octal and Hexadecimal Bases are and then move on to how to convert both of them to Binary and then discuss in each case, how to convert Binary to Octal and Binary to Hexadecimal.

What is the Octal Base System (Base 8)?

Instead of counting with 10 digits (as in Base 10) or two digits (as in Base 2), in the Octal system we use 8 digits. Again the subscript is used to denote the number bases used, in this case, we use subscript 8.

The first 8 digits (0 to 7) in Octal are the same in decimal, so we can easily memorize the conversions from octal to decimal to binary, as below:

0₈ is 0₁₀ is 0₂

1₈ is 1₁₀ is 1₂

2₈ is 2₁₀ is 10₂

3₈ is 3₁₀ is 11₂

4₈ is 4₁₀ is 100₂

5₈ is 5₁₀ is 101₂

6₈ is 6₁₀ is 110₂

7₈ is 7₁₀ is 111₂

How do we convert Octal to Binary?

We know how to convert single-digit numbers from Octal to Binary, simply refer to the above and consider that 0–7 are the same in Octal as they are in Decimal, then convert from Decimal to Binary.

What if the Octal number has more than one digit?

70₈

Simply split the digits from right to left into octal to binary conversions, writing the answer right to left.

Each digit, in this example going right to left, 0 then 7 should correspond to 3 binary digits each.

0₈ = 000
7₈ = 111

Combine these two groups of three binary digits as below to produce your final binary representation:

70₈ = 111 000₂

Refer to the following table and memorize it:

Recall that binary numbers from right to left increase in place value.

Special Rule: If the group of three binary digits farthest to the left you end up with after the conversion have leading 0s e.g. 001 001 — simply omit them.

So, if you end up with 001 001₂

This should be written as 1 001₂

One more example — 321₈ in binary

Start from right to left and write 1 in Octal (which is the same in Decimal) with three digits in binary.

1₈ = 001₂

Then move on to 2, the next digit going right to left.

2₈ = 010₂

Finally, move on to 3 and write that, omitting any leading 0s.

3₈ = 11₂ (note that we do not write a 0 in the 4’s place)

Your final binary representation of 321₈ is the above three steps combined from right to left:

321₈ = 11 010 001₂

How to convert a Binary number to an Octal number?

Let’s start with an example and a short explanation of how to convert a binary number into an Octal number. We will use the following binary number as an example:

11101110111₂

Starting from right to left and splitting the digits into groups of three, I will use a dash to separate them for ease of viewing:

11-101-110-111₂

Note the last group of binary digits farthest to the left is not a group of three digits, because the leading 0 has been omitted. Simply add it again, now you should have something like this:

011–101–110–111₂

Now simply convert from right to left, those three-digit binary groups into Octal (which is the same as converting 3 digit binary numbers into decimal).

111₂ = 7₈
110₂ = 6₈
101₂ = 5₈
011₂ = 3₈

Write the answer to these conversions from right to left, starting with the first conversion you did (111₂ = 7₈) and finishing with the final conversion (011₂ = 3₈).

Your final answer is: 11101110111₂ = 3567₈

How to convert a Hexadecimal number to a Binary number?

In hexadecimal, also known as Base 16 — we count with 16 digits as opposed to 2 in binary, 8 in octal, and 10 in decimal. Hexadecimal is increasingly used throughout Computing, for example in the Internet Protocol v6 system within computer networking.

The digits used for counting include letters this time:

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E ,F

Refer to the following chart to note the similarities between Hexadecimal and Decimal and then their conversions to Binary.

An easy way to memorize the above is that all Hexadecimal numbers from 0–9 are the same as they are in Decimal, then it is straightforward enough to convert to binary.

In the case that you are dealing with 0–9 numbers, simply convert to binary but use a 4 digit representation in binary.

After 9 comes A, B, C, D, E, and F. These correspond to their incremental values in decimal e.g. A = 10, B = 11, C = 12, and so on.

Let us convert the Hexadecimal number ACE₁₆ to binary.

Starting from right to left again, as we did with Octal — begin with the letter E₁₆ but convert this into four groups of binary digits, including leading 0s in all groups of digits bar the final group of digits farthest to the left.

E₁₆ = 1110₂
C₁₆ = 1100₂
A₁₆ = 1010₂

Now write the above binary representation starting from right to left. In the special case that you have leading 0s at the end of your binary conversion in the farthest to left places, omit them.

ACE₁₆ = 1010 1100 1110₂

Now let’s try another example: 3AF₁₆

Starting from right to left, convert each of the Hexadecimal digits into four groups of binary digits — with leading 0s in all places taking up the 4 digit values where required, bar the farthest to the left group of 4 digits — where you omit the leading 0s.

F₁₆ = 1111₂
A₁₆ = 1010₂
3₁₆ = 11₂
(note that we have omitted the leading 0s from the final group of ‘4’ digit binary numbers in our Hexadecimal to Binary conversion)

The final representation is 3AF₁₆ = 11 1010 1111₂

How to convert a Binary number to Hexadecimal?

This is a similar process to the one that we covered for Binary to Octal conversions, except you are using four-digit binary representations instead of 3.

Let’s use another example — this time starting with a Binary number and converting to Hexadecimal.

11111011011₂

Split the above binary number from right to left into groups of four binary digits, if there are not enough digits in the final group farthest to the left, add leading 0s.

Then convert these groups into decimal and use the decimal number to figure out whether you are dealing with 0–9 or A — F.

Recall that the numbers 0–9 in Hexadecimal are the same as they are in Decimal and the letters that follow, A — F, correspond to:

A = 10
B = 11
C = 12
D = 13
E = 14
F = 15

0111-1101-1011₂

Add leading 0s if you do not have solid groups of 4 binary digits.

Then start from right to left with your groups of 4 digits, converting them from Binary to Decimal to Hexadecimal. Note, you can convert straight from Binary to Hexadecimal if you have memorized the chart given above in this article.

1011₂ = B₁₆ — this is the same as the number 11 in Decimal, recall that after 0–9 digits we increment by 1 corresponding to the starting letters of the alphabet (e.g A = 10, B = 11).

1101₂ = D₁₆ — this is the same as the number 13 in decimal, consult the list above if you are not sure.

0111₂ = 7₁₆ — this is the same as the number 7 in decimal, which is the same in Hexadecimal.

Now write the Hexadecimal conversions above, starting from right to left.

Your final answer will look like this: 11111011011₂ = 7DB₁₆

How do we convert Octal & Hexadecimal to Decimal and vice-versa?

There is no shortcut to do this and in my experience, I have found the simplest route is to convert Octal / Hexadecimal to Binary then to Decimal.

If you need to convert a Decimal number to Octal or Hexadecimal — convert it first to Binary.

Always use binary as the proxy or intermediary between conversions of this type.

Further Practice

This website is extremely useful for generating a quiz of Decimal, Binary, Octal, and Hexadecimal conversion questions — please do practice with it as much as you can, until you are consistently scoring 100% in your answers:

Summary

In the Octal and Hexadecimal number systems, the numerical digits used for counting correspond to their decimal equivalents.

In Octal: the numbers 0–8 correspond to the same in Decimal.
In Hexadecimal: the numbers 0–9 correspond to the same in Decimal.

We already know how to convert Decimal to Binary and vice versa, so we can use those conversions

In the special case of Hexadecimal, we typically use the letters A — F following the number 9 to denote 10–15. I.E the numbers used for counting in Hex are:

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A(10), B(11), C(12), D(13), E(14), F(15)

We convert Octal to Binary by splitting the octal number up right to left into single-digit values which should be converted into three-digit binary representations.

In Hexadecimal, the process is similar. We can convert from Hexadecimal to Decimal and then to Binary — representing the binary number in groups of four digits.

The leading 0s in the group of binary numbers we have converted to in the farthest to the left group of binary numbers can be omitted.

I hope you enjoyed reading this article. For further information about me and my work, please view my portfolio and blog.

--

--

No responses yet