Hexadecimal

Hexadecimal is a numbering system used by mini-computers and mainframes to assist in reading the contents of main memory. Can you imagine how hard it would be to read and how much paper would be wasted if every time you printed out the contents of main memory, it printed out in binary? It takes 8 bits to represent every number and every character available to the computer. Count the number of characters, including blank spaces, in the first line on this screen and then multiply that number by 8. That is how many one's and zero's it would take to represent just the first line. Hexadecimal, or Hex, is base 16. This numbering system allows 16 digits to represent all numbers, not just 2 as binary did. Hex has a number line, also. You begin with one on the far right side and multiply by 16(the base) for every number after that.

Hex Number Line

4096 256 16 1

Another difference in decimal and Hex is that Hex only allows you a single digit to represent the 16 digits in the base.

Decimal Hex

- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- A
- B
- C
- D
- E
- F

You will notice that decimal and hex look identical for the numbers 1 through 9. Then because hex only allows one digit, 10 in decimal becomes A in hex, 11 in decimal becomes B in hex, and so on. For the numbers 1 through 15, converting to hex is just a matter of knowing what the numbers equivalent is. For example, a 2 in decimal is a 2 in hex, a 7 in decimal is a 7 in hex, a 12 in decimal is a C in hex.

To convert from decimal to hex for numbers larger than 15, you can take the number in decimal and divide it by 16(the base) and save the remainder, The remainder becomes the hex equivalent.

Example:

If you wanted to find the hex equivalent of the decimal number 45, you would:

(Find Hex example 1 in your packet.)

In this example, 16 will divide into 45, 2 times with a remainder of 13, but remember we are trying to find the hex equivalent of 45 and there is no 13 in hex. 13 in hex is D, so we write D out to the side of the 2. We then divide 16 into 2 and it will not go, so we write a zero under the 2 and have that 2 as the remainder. To read this hex number, always start at the bottom and read up. The hex equivalent of 45 is 2D. If we were to plug that in under the number line we could check to make sure we were correct.

16 1 (number line)

2 D

To check and make sure you have the correct hex number, place the 2 under the 16 in the number line and the D under the 1. Now we take the 2 and multiply it by the number above it in the number line, 16. 2 times 16 is 32. We then multiply D(which is 13) by the number it is below in the number line. 13 times 1 is 13. We then add the two answers together, 32 + 13 = 45. We now know that we have the correct hex number. Let's do another one. Find the hex equivalent of the decimal number 272.

16 | 272

--------

16 | 17 0 (See Hex example 2 in packet)

--------

16 | 1 1

--------

0 1

In this example, you divide 272 by 16(the base). 16 will go into 272, 17 times with a remainder of 0. You then divide 16 into 17 and find that it will go into 17 1 time with a remainder of 1. Then you divide 16 into 1 and find that it will not go into 1, so you write down a zero, but you still have that last 1 as the remainder. Reading from the bottom up, the hex equivalent of 272 is 110. Again, if you plug this into the number line you can find out if you are correct.

256 16 1 (number line)

1 1 0

Now you multiply the number in the number line by the number that is below it. 256 times one is 256. 16 time 1 is 16. 1 times 0 is 0. Now add all the answers together. 256 + 16 + 0 = 272. We have the correct equivalent.

To convert from Hex to Decimal

To get the decimal equivalent of a hex number, just plug the number under the number line, multiply, and then add.

Example:

Hex number **256 16 1**

32 3 2

16 times 3 = 48

1 times 2 = 2

48 + 2 = 50, so the decimal equivalent of 32 is 50.

Hex number **256 16 1**

5F 5 F

16 times 5 = 80

1 times F(which is 15) = 15

80 + 15 = 95, so the decimal equivalent of 5F is 95

To add and subtract in hex, you may use the Hex addition and subtraction chart in the packet you received at orientation. You will notice that across the top of the chart are the numbers 1 through F, and down the left side you will find the same numbers. This chart is in Hex so you will not need to convert anything. To use the chart to add in hex: first find one number in the equation at the top of the chart, then find the other number in the equation at the left side of the chart, where the two numbers intersect is the answer.

Example: __1 2 3 4 5 6 7 8 9 A B__

1 | 2 3 4 5 6 7 8 9 A B C

2 | 3 4 5 6 7 8 9 A B C D

3 | 4 5 6 7 8 9 A B C D E

If we wanted to add 2 + 3 in hex, we would find 2 at the top of the chart and 3 to the far left side of the chart. We would then follow those two numbers down and right until they intersected. Where they intersect is the answer, 5.

To use the same chart for subtraction, you always, always, always find the bottom number in the equation at the top of the chart. You then proceed down that column, without looking left or right, until you come to the top number in the equation, then follow that row all the way to the left of the chart. The number on the far left of the chart is the answer. Using the chart above, if we wanted to subtract 4 from 6, we would find the 4 at the top of the chart, then go straight down the 4 column until you reach the 6, remember not to look to the left or right, just go straight down. Then when you reach the 6, go all the way to the left of the chart and that number will be your answer.