Skip to content

Decimal and Hexadecimal conversions

Every network engineer must know how to convert decimal to hex and hex to decimal.

Decimal to Hexadecimal conversion

To learn how to convert a decimal number to its hexadecimal format, let’s take an example.

Suppose we want to convert 39619 into Hex.

  1. We take 39619 and divide it by 16:  39619/16 = 2476.1875. We note the remainder of the division (aka the Modulo). 39619 mod 16 = 3.
  2. We take 2476. We divide it by 16:  2476/16 = 154.75. We note the remainder of the division: 2476 mod 16 = 12
  3. We take 154 and divide it by 16:  154/16 = 9.625. We note the remainder of the division: 154 mod 16 = 10
  4. We take 9 and divide it by 16:  9/16 = 0. We note the remainder of the division: 9 mod 16 = 9
  5. We stop because we encountered a 0 in step 4.
  6. Now we read the series of modulos we found in steps 1 to 4, in the reverse order: 9 10 12 3
  7. We convert each modulo of the sequence to its hex format:decimal-hexadecimal-conversions-table2
  8. This gives us 9AC3 which is the hexadecimal format of 3619.
Figure 1: Steps to convert decimal 39619 to its hex format

Hexadecimal to Decimal conversion

Here are the steps to convert a hexadecimal string to decimal:

  1. Take each hex character apart
  2. Convert each hex character to its decimal value
  3. Multiply each decimal value by the corresponding hex position, in the whole hex string.

Let’s take an example. We want to convert the hex string AE0D to its decimal value. By the way, you must learn this table by heart:

Hexadecimal-to-decimal chart

Back to our example. We begin by taking each hex character apart and convert it to its decimal value. We get the following table:

table1Now we determine the hex position of each hex character:

table2We multiply each decimal value by the corresponding hex position:




Last, we do the sum total:


So, AE0D (in hexadecimal) = 44557 (in decimal)


Published inNetworking Basics

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

copyright 2020