Number Conversion - Decimal to Hexadecimal and Hexadecimal to Decimal



UpdatedUpdatedJune 02 - 2017June 02 - 2017

Decimal to Hexadecimal:

Decimal (base-10) to hexadecimal (base-16) conversion:
Step 1: Divide the decimal number by 16 (16 comes from the base value of hexadecimal number system).
Step 2: The remainder is the LSD (least significant digit) of the hexadecimal number.
Step 3: Divide the quotient from Step 1 by 16 again.
Step 4: The new remainder from Step 3 is the next digit (from right to left) of the hexadecimal number.
Step 5: The process continues until we get 0 as the quotient. The remainder from this step is the MSD (most significant digit) of the hexadecimal number.


Example:

Decimal number: 4510
NumeratorDenominatorQuotientRemainder
4516213 (LSD)
21602 (MSD)
We know from [Digital Number Systems - Introduction] that 1310 = D16
So, the hexadecimal representation: 2D16


Hexadecimal to Decimal:

Hexadecimal (base-16) to decimal (base-10) conversion:
From right (LSB) to left (MSB) we will take each digit and multiply them by 16x and later add the results together. Here x is the corresponding position of a digit and 16 comes from the base value of hexadecimal number system.


Example:

Hexadecimal number: 2D16
Number:2 (MSB)D (LSB)
Position:10
We know, D16 = 1310
Now, (2 x 161) + (13 x 160)
= 32 + 13
= 45

So, the decimal representation: 4510