## Why is the Hexadecimal numbering system used?

The **hexadecimal numbering system** (base-16) is mainly used to simplify the representation of binary numbers and for the digital handling of colors.

## The Hexadecimal system and the binary system

The useful relationship between hexadecimal and decimal is not obvious, however it is with the binary system.

The number 255 in decimal is expressed in binary as 8 “ones” (11111111). This and other binary numbers are confusing to interpret, but if we transform it to the hexadecimal system, it will have only two digits instead of 8. From the above it follows that: expressing, remembering and using this format is easier.

The following table shows a comparison of the numbers in the decimal, binary and hexadecimal system.

Conversion table between decimal, binary and hexadecimal numbering systems

Examples of converting from binary to hexadecimal

- 11111111
_{2}= FF_{16} - 10101010
_{2}= AA_{16} - 00111100
_{2}= 3C_{16}

As you can see, the hexadecimal system is more readable. First the first 4 digits of the binary number are converted and then the next ones.

### How to convert a binary number to hexadecimal?

**Example 1**: Convert the binary number 10001010 to hexadecimal.

- Write down the binary number: 10001010
- Group all the digits in sets of four starting from the LSB (far right). Add zeros to the left of the last digit if there aren’t enough digits to make a set of four: 1000 1010
- Use the table above to convert each set of four into a hexadecimal digit: 1000 = 8, 1010 = A

So, 8A is the hexadecimal equivalent to the binary number 10001010

**Example 2**: Convert the binary number 10111010 to hexadecimal.

- Write down the binary number: 10111010
- Group all the digits in sets of four starting from the LSB (far right). Add zeros to the left of the last digit if there aren’t enough digits to make a set of four: 1011 1010
- Use the table above to convert each set of four into a hexadecimal digit: 1011 = B, 1010 = A.

So, BA is the hexadecimal equivalent to the binary number 10111010.

### How to convert a hexadecimal number to binary?

**Example 3**: How to convert hexadecimal number 8A to binary?

- Look up each hexadecimal digit to obtain the equivalent group of four binary digits. You can use the table above to make these conversions.

(8)_{16} = (1000)_{2}

(A)_{16} = (1010)_{2}

- Group each value of step 1: 1000 1010
- Join these values and remove zeros at left (if necessary) to get the binary result: 10001010

So, 10001010 is the binary equivalent of hexadecimal number 8A.

**Example 4**: How to convert hexadecimal number BA to binary?

- Look up each hexadecimal digit to obtain the equivalent group of four binary digits. You can use the table above to make these conversions.

(B)_{16} = (1011)_{2}

(A)_{16} = (1010)_{2}

- Group each value of step 1: 1011 1010
- Join these values and remove zeros at left (if necessary) to get the binary result: 10111010

So, 10111010 is the binary equivalent of hexadecimal number BA.

## The Hexadecimal numbering system and the decimal system

It can be seen that in the Hexadecimal Numbering System the letters from “A” to “F” are used to obtain the numbers from 10 to 15 of the decimal system.

### How to convert a decimal number to hexadecimal?

Divide the number in decimal by 16 until the quotient is zero, and then the remaining numbers are read from bottom to top.

**Example 5**: Convert the decimal number 2741 to hexadecimal.

Divide (2741)_{10} successively by 16 until the quotient is 0:

- 2741/16 = 171, remainder is 5
- 171/16 = 10, remainder is 11
- 10/16 = 0, remainder is 10

Read from the bottom (MSB) to top (LSB) as AB5. So, AB5 is the hexadecimal equivalent of decimal number 2741

**Example 6**: Convert decimal number 47321 to hexadecimal.

Divide (47321) 10 successively by 16 until the quotient is 0:

- 47321/16 = 2957, remainder is 9
- 2957/16 = 184, remainder is 13
- 184/16 = 11, remainder is 8
- 11/16 = 0, remainder is 11

Read from the bottom (MSB) to top (LSB) as B8D9. So, B8D9 is the hexadecimal equivalent of decimal number 47321

### How to convert a hexadecimal number to decimal?

**Example 7**: Convert Hexadecimal number AB5 to decimal.

- Write down the hexadecimal number: (AB5)
_{16} - Show each digit place as an increasing power of 16:

Ax162 + Bx161 + 5×160 - Convert each hexadecimal digits values to decimal values, then perform the math:

10 x 256 + 11 x 16 + 5 x 1 = (2741) 10

So, the number 2741 is the decimal equivalent of the hexadecimal number AB5

**Example 8**: Convert Hexadecimal number B8D9 to decimal.

- Write down the hexadecimal number: (B8D9)
_{16} - Show each digit place as an increasing power of 16:

B x 163 + 8 x 162 + D x 161 + 9 x 160 - Convert each hexadecimal digits values to decimal values then perform the math:
- 11 x 4096 + 8 x 256 + 13 x 16 + 9 x 1 = (47321)
_{10}

So, the number 47321 is the decimal equivalent of the hexadecimal number B8D9.

Notes:

- LSB = Least Significant Bit
- MSB = Most Significant Bit

### More Digital Tutorials

- What is the difference between Analog & Digital?
- What is a logic circuit?
- Digital logic levels (high, low, 1, 0)
- The truth table
- Boolean algebra
- Karnaugh Map (K-map)
- Binary number system
- Hexadecimal numbering system
- BCD code – binary coded decimal
- Gray code – Gray code table
- Aiken code – Excess 3 code
- AND gate
- NAND gate
- OR gate
- NOR gate
- NOT gate
- XOR gate
- How to build a NAND gate with transistors & diodes?
- OR & AND logic gates made with diodes
- The combinational circuit
- The sequential circuit
- JK Flip-Flop
- What is a binary decoder?