Hexadecimal Numbers

 

      Hexadecimal numbers are another form of computer code, but is mostly associated with memory (as far as I know). The way our number system, the decimal system, uses the digits 0-9, and the binary system uses 0 and 1, well the hexadecimal system uses the digits 0-9 AND the letter A-F. This is so each hexadecimal can use a one-digit number to represent 16 numbers.

      Hexadecimal numbers go in the form of 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F. The first form of conversion we use is to convert decimal numbers to hexadecimal is by using a method which uses binary conversion; we convert the number to binary and then to hexadecimal.

      Let's convert the number 739 to hexadecimal. First, convert it to binary.

 

Decimal to binary conversion

2~10 2~9 2~8 2~7 2~6 2~5 2~4 2~3 2~2 2~1 2~0
1024 512 256 128 64 32 16 8 4 2 1
0 1 0 1 1 1 0 0 0 1 1

 

      Now we take the binary number in segments of four, starting with the least significant digit, or the right hand side. So we can take it that the first segment is 0011, the second is 1110, and the third is 10, but we add two 0's to the start to make it four digits; the third is now 0010. We look at the table below to see what the hexadecimal digits are.

 

Hexadecimal numbers

2~3 2~2 2~1 2~1 Decimal Hexadecimal
0 0 0 0 0 0
0 0 0 1 1 1
0 0 1 0 2 2
0 0 1 1 3 3
0 1 0 0 4 4
0 1 0 1 5 5
0 1 1 0 6 6
0 1 1 1 7 7
1 0 0 0 8 8
1 0 0 1 9 9
1 0 1 0 10 A
1 0 1 1 11 B
1 1 0 0 12 C
1 1 0 1 13 D
1 1 1 0 14 E
1 1 1 1 15 F

 

      What we do is see what segment corresponds to what hexadecimal number. Starting from the most significant side (left hand side), the hexadecimal number is 2, the next is E, and the last is 3. Put these together and you have 2E3. Just to wrap things up, any hexadecimal number should be denoted with a small H at the end, e.g. 2E3H and C7FH.

      The next method is a shorter method, but may not necessarily be easier in some cases. We just take the decimal number to be converted, divide by 16 until the numerator is 0, and stop there. We will convert the number 89066, since it is a large number.

 

Dividing to get hexadecimal numbers

16 |89066 
  16 |5566     R = 10
    16 |347       R = 14
      16 |21     R = 11
        16 |1     R = 5
   R = 1

 

      Starting with the last remainder, we convert the remainders into hexadecimal numbers; 1 5 11 14 10 = 15BEAH = the hexadecimal number! That's how conversion is done, the second way. Now, to convert hexadecimal back to decimal is easy. Just set up a table as I have done below.

 

Converting hexadecimal to decimal

16~4 16~3 16~2 16~1 16~0 Power of 16
65536 4096 256 16 1 Power - Decimal
1 5 B E A Hexadecimal
1 5 11 14 10 Hexadecimal - Decimal
65536 20480 2816 224 10 = 89066

 

      As can be observed here, the hexadecimal digits was placed under its corresponding power of 16, and multiplied, giving the decimal number on the bottom line e.g. 16~2 x B = 2816 (256 x 11 = 2816). All these decimal numbers can be added up to give the original decimal number : 89066!

      You can also convert it back to decimal using the binary method, except backwards. Next, you can learn about other forms of number codes, e.g. BCD and Octal, including other small things.

 

BCD and Octal Numbers