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 concisely and easily readable.

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

Conversion between Binary and Hexadecimal

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

  • Divide the binary number into groups of 4 digits, starting from the right.
  • If the last group does not have 4 digits, add zeros to the left to complete 4 digits.
  • 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.

  • Group into 4-digit groups: 0001 0110 1011 0100

  • Convert each group:

    • 0001 becomes 1
    • 0110 becomes 6
    • 1011 becomes B
    • 0100 becomes 4
  • Join the obtained hexadecimal values: 16B4

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

Conversion from Hexadecimal to Binary

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

  • 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.

  • Find the equivalents of each hexadecimal digit to a block of 4 bits

    • 2 is 0010
    • A is 1010
    • 7 is 0111
  • Join 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: