Hexadecimal number system (Hex) is just like decimal and binary number system. Where in decimal system the base is 10 and in binary system the base is 2, the base in hexadecimal system is 16. In Hex, we use digits 0-9 and alphabets A to F. The decimal numbers 0-9 are same in Hex system but for decimal numbers 10-15, we have A-F in Hex. For decimal numbers 16-25, we resume our counting of Hex from 10. Since we mostly use decimal numbers, it is easier to understand Hex in terms of decimal numbers. The following table shows how each number in decimal has an equivalent number in Hex.

Dec Hex
0 0
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
10 a
11 b
12 c
13 d
14 e
15 f

## Hex conversion

There’s no way we can remember this table or draw it every time we are using Hex system, but we can easily convert from decimal system to Hex and vice versa. If you know how to convert from binary to decimal or from decimal to binary, Hex conversion will be very easy for you because it is similar to binary conversion.

## Hex to Decimal

Lets’ start by converting a Hex number (4FD in this case) to a decimal number. For this, we will use place values. Starting from the right hand side, D is the lowest number and 4 is the highest number.  So, we will multiply the lowest number with the lowest power of 16. The lowest power of 16 is 0. Then multiply the next number (F in this case) with the next highest power of 16 (which is 1). Lastly, multiply the highest number (4 in this case) with the highest power of 16 (which is 2 here). Then add all the products to find the decimal equivalent of 4FD. It comes out to be 1277.  We Also have age calculator, which you should check out to know your exact age.

• Remember, you must start from lowest power 0 but there’s no limit to highest power. If the Hex number has 4 digits, the highest power will be 3.

### Example:

4FD = (4 x 162) + (F x 161) + (D x160)

= (4 x 256) + (15 x 16) + (13 x 1)

= 1024 + 240 + 13

= 1277

## Decimal to Hex

Let’s convert the decimal number 1277 back to Hex. We will also know for sure if our conversion is correct because we know that it should be 4FD. We will use synthetic division for conversion from decimal to Hex.  This means that we will continuously divide the number by 16 unless our number becomes less than 16. This process is a little complicated so we will divide it into steps.

1. Divide the decimal number by 16. (1277 / 16 = 79.8125)
2. We only want whole numbers so we will we subtract the whole part from the actual number. (79.8125 – 79 = 0.8125)
3. Now multiply the decimal part with 16 to make it a whole number as well. (0.8125 x 16 = 13)
4. Now again divide the number by 16. ( 79 / 16 = 4.9375)
5. Repeat step 2 and subtract the whole part. (4.9375 – 4 = 0.9375)
6. Repeat step 3 and multiply the decimal part with 16. (0.9375 x 16 = 15)
7. Since 4 is less than 16. We will not divide anymore.
8. Starting from the lower left side, the outer numbers are our answer. (4, 15, and 13)
9. In Hex, we have 15 = F and 13 = D.
10. So, 1233 in decimal is equal to 4FD in Hex.

### Example: Once, we are clear on conversions, we will move towards arithmetic operations on Hex numbers. Addition of Hex numbers is quite similar to how we do it in case of decimal numbers.

1. Start from right hand side, add the two numbers by adding their decimal values. (A + B= 10 + 11 =21)
2. Then convert the sum from decimal to hex. (21 in decimal is 15 in Hex)
3. If the answer has two digits, left most digit is carried to the next numbers. (5 is written in answer and 1 is carried)
4. Add the next two numbers and the carry. (D+ 2 + 1 = 13+ 2+ 1 = 16)
5. Repeat step 2. (16 in decimal is 10 in Hex. We will write 0 in answer and 1 is carried to the next numbers.)
6. Repeat step 4 and 2.  (8 + 4 + 1 = 13, 13 in decimal is D in Hex).

### Example:

 1 1 4 2 A + 8 D B D 0 5

## Hex Subtraction

1. Start from right hand side, subtract the decimal value of Hex number in second row from the decimal value of Hex number in first row.  (A-B = 10-11)
2. If the number in first row is smaller than the number in second row (A<B), borrow from the next number in the first row. In hex, ‘16’ is borrowed instead of ‘1’.  (4 is reduced to 3 and A is increased by 16).
3. Carry out the subtraction after borrowing and convert the answer to Hex. (16+A–B = 16+10-11 = 15, 15 in decimal in F in Hex)
4. Repeat step 1 and 2. Repeat step 3 if necessary. (3 < C so another ‘16’ is borrowed from D, 3+16–C = 3+16-12 = 7. Step 3 is not necessary because 7 in decimal is 7 in Hex too.)
5. Repeat step 4. (D is reduced to C since it gave ‘1’ to 3. C-8 = 12-8=4).

### Example:

 0 16 16 D 4 A - 8 C B 4 7 F

## Hex Multiplication

Multiplication in Hex is same as multiplication in decimal.

1. Multiply the right most digit in second row with all the digits in the first row. (C x D = 12x13 =156, 156=9C, C is written as answer and 9 is carried, (Cx2)+9 = (12x2)+9=24+9=33, 33=21, 1 is written as answer and 2 is carried)
2. Write a ‘0’ in the second row of answers and write your answers of the next step after this.
3. Multiply the next digit in second row with all the digits in first row. (A x D = 10x13 =130, 130=82, 2 is written as answer and 8 is carried, (Ax2)+8 = (10x2)+8=20+8=28, 28=1C, C is written as answer and 1 is carried)
4. Now we have two rows of answers from step 1 and step 3. Add the two rows to get the final row of answer. (C+0 =C, 1+2=3, 2+C=E, 0+1= 1)

### Example:

 1 8 0 2 9 0 2 D x A C 0 2 1 C + 1 C 2 0 1 E 3 C

## Hex Division

Long division in Hex is same as long division in decimal except that subtraction and addition is done in Hex.

1. Start from the left most digit in dividend (FED). Multiply the divisor (C4) with a suitable number so that the answer is less than the first two digits of the dividend. (C4 x1 = C4, C4<FE)
2. Subtract the product from the dividend. (F-C=15-12=3, E– 4=14-4=10 ->A)
3. Take the third digit of the dividend along with the difference obtained in step 2.
4. Repeat step 1. (C4x 4 = 196x4 =784, 784 in decimal is 310 in Hex and less than 3AD)
5. Repeat step 2. (3-3=0, A-1=10-1=9, D-0=D)
6. If the difference obtained in step 5 is less than the divisor, it is considered as the remainder. (9D is remainder)
7. The quotient is the number multiplied by the divisor in step 1 and 4. (14 is the quotient)

### Example:

 1 4 C 4 F E D - C 4 3 A D - 3 1 0 0 9 D