Language: EN

como-convertir-binario-hexadecimal

How to convert between binary and hexadecimal numbers

The hexadecimal system is an extension of the decimal system that uses sixteen digits, 0 to 9 and A to F.

For example, the hexadecimal number 2F represents (2 * 16^1) + (F * 16^0) (which is equal to 47 in decimal).

The advantage of the hexadecimal system is that it provides a very compact representation. For this reason, it is widely used in programming to represent binary values in a concise and easily readable manner.

Additionally, each hexadecimal digit represents four bits (also called a nibble) in the binary system. Therefore, the conversion from hexadecimal to binary is very, very simple.

Conversion between Binary and Hexadecimal

To convert a binary number to hexadecimal, we do the following:

  1. We divide the binary number into groups of 4 digits, starting from the right.
  2. If the last group does not have 4 digits, we add zeros to the left to complete 4 digits.
  3. We convert each group of 4 binary digits into its hexadecimal equivalent.

Here is the conversion table:

Binary (4 bits)Hexadecimal
00000
00011
00102
00113
01004
01015
01106
01117
10008
10019
1010A
1011B
1100C
1101D
1110E
1111F

Example of binary to hexadecimal conversion

We will convert the binary number 101101011010 to hexadecimal.

  • We group into groups of 4 digits: 0001 0110 1011 0100

  • We convert each group:

    • 0001 converts to 1
    • 0110 converts to 6
    • 1011 converts to B
    • 0100 converts to 4
  • We combine the obtained hexadecimal values: 16B4

Thus, 101101011010 in binary is equal to 16B4 in hexadecimal.

Conversion from hexadecimal to Binary

Converting a hexadecimal number to binary is not much more difficult. We simply do the reverse process.

  • We convert each hexadecimal digit into 4 bits using the previous conversion table.

Example of hexadecimal to binary conversion

We will convert the hexadecimal number 2A7 to binary.

  • We look for the equivalents of each hexadecimal digit to a block of 4 bits

    • 2 is 0010
    • A is 1010
    • 7 is 0111
  • We combine the 4-bit blocks, 0010 1010 0111

Therefore, 2A7 in hexadecimal is equal to 001010100111 in binary.

Try the converter

Enter a binary number:
Enter a hexadecimal number: