163 162 161 160 column values 4096 256 16 1 column values
4 11 15 0 hex values
16 384 2816 240 0 denary column totals Total = 16 384 + 2816 + 240 + 0 = 19 44010
Converting binary to hex
This is very easy. Four binary bits can have minimum and maximum values of 00002up to 11112. Converting this into denary by putting in the column headers of: 8, 4, 2 and 1 results in a minimum value of 0 and a maximum value of 1510. Doesn’t this fit into hex perfectly!
This means that any group of four bits can be translated directly into a single hex digit. Just put 8, 4, 2 and 1 over the group of bits and add up the values wherever a 1 appears in the binary group.
Example
Convert 1000000101010112 to hex
Step 1 Starting from the right-hand end, chop the binary number into groups of four.
100/ 0000/ 1010/ 1011/
Step 2 Treat each group of four bits as a separate entity. The right-hand group is 1011 so this will convert to:
8 4 2 1 column headers 1 0 1 1 binary number 8 0 2 1 column values
The total will then be 8 + 0 + 2 + 1 = 1110or in hex, B.
The right-hand side binary group can now be replaced by the hex value B.
100/ 0000/ 1010/ 1011/
B
Step 3 The second group can be treated in the same manner. The bits are 1010 and by comparing them with the 8, 4, 2, 1 header values this means the total value is (8 ⫻1) + (4 ⫻ 0) + (2 ⫻ 1) + (1 ⫻1) = 8 + 0 + 2 + 0 = 1010or in hex, A.
We have now completed two of the groups.
100/ 0000/ 1010/ 1011/
A B
Step 4 The next group consists of all zeros so we can go straight to an answer of zero. The result so far will be:
100/ 0000/ 1010/ 1011/
0 A B
Step 5 The last group is incomplete so only the column headings of 4, 2, and 1 are used. In this case, the 4 is counted but the 2 and the 1 are ignored because of the zeros. This gives a final result of:
100/ 0000/ 1010/ 1011/
4 0 A B
So, 1000000101010112 = 40ABH.
Having chopped up the binary number into groups of four the process is the same regardless of the length of the number. Always remember to start chopping from the right-hand side.
Example
Convert the number 11000111110012to hex
Split it into groups of four starting from the right-hand side 1/ 1000/ 1111/ 1001/
Add column headers of 8 4 2 1 to each group 1 8421 8421 8421 column headings 1/ 1000/ 1111/ 1001 binary number
1 8 8421 81 column values 1 8 15 9 group value in denary
Now just convert group values to hex as necessary. In this example only the second group 15, will need changing to F.
Final result is 11000111110012 = 18F9H.
Converting hex to binary
This is just the reverse of the last process. Simply take each hex number and express it as a four bit binary number.
As we saw in the last section, a four-bit number has column header values of 8, 4, 2 and 1, so conversion is just a matter of using these values to build up the required value. All columns used are given a value of 1 in binary and all unused columns are left as zero.
When you are converting small numbers like 3H we must remember to add zeros on the left-hand side to make sure that each hex digit becomes a group of four bits.
Imagine that we would like to convert 5H to binary. Looking at the column header values of 8, 4, 2 and 1, how can we make the value 5?
The answer is to add a 4 and a 1. Taking each column in turn: we do not need to use an 8 so the first column is a 0. We do want a 4 so this is selected by putting a 1 in this column, no 2 so make this 0 and finally put a 1 in the last column to select the value of 1. The 5H is converted to 01012. All values between 0 and FH are converted in a similar way.
Example
Convert 2F6CH to binary
Step 1 Write the whole hex number out with enough space to be able to put the binary figures underneath
2 F 6 C
Step 2 Put the column header values below each hex digit
2 F 6 C
8421 8421 8421 8421
Step 3 The hex C is 1210that can be made of 8 + 4 so we put a binary 1 in the 8 and the 4 columns. The four-bit number is now 11002
2 F 6 C
8421 8421 8421 8421 1100
Step 4 Now do the same for the next column. The hex number is 6, which is made of 4 + 2, which are the middle two columns. This will result in the binary group 01102
2 F 6 C
8421 8421 8421 8421 0110 1100
Step 5 Since 8 + 4 + 2 + 1 = 15, the hex F will become 11112
2 F 6 C
8421 8421 8421 8421 1111 0110 1100
Step 6 Finally, the last digit is 2 and since this corresponds to the value of the second column it will be written as 00102
2 F 6 C
8421 8421 8421 8421 0010 1111 0110 1100
The final result is 2F6CH = 00101111011011002.
But do we include the two leading zeros? There are two answers, ‘yes’
and ‘no’ but that’s not very helpful. We need to ask another question:
why did we do the conversion? were we doing math or micro- processors? If we were working on a microprocessor system then the resulting 16 bits would represent 16 voltages being carried on 16 wires. As the numbers change, all the wires must be able to switch between 0 V and 3.3 V for binary levels 0 and 1. This means, of course, that all 16 wires must present so we should include the binary levels on all of them.
If the conversion was purely mathematical, then since leading (left- hand end) zeros have no mathematical value there is no point in including them in the answer.
Method
1
Write down the hex number but make it well spaced.2
Using the column header values of 8, 4, 2 and 1, convert each hex number to a four bit binary number.3
Add leading zeros to ensure that every hex digit is represented by four bits.Example
Convert 1E08BH to binary Step 1
1 E 0 8 B
8421 8421 8421 8421 8421 Step 2
0001 1110 0000 1000 1011 So, 1E08BH = 000111100000100010112.