Using hexadecimal to represent machine code

Hexadecimal code is the lowest form of programming language used by programmers. It cannot be understood by the processor but it makes binary more readable for humans.

Earlier, we saw how 180 can be coverted to binary as 10110100

Using hexadecimal the same instruction can be represented as B4

In hexadecimal the letter B represents the number 11. Hexadecimal code works to the power of 16 (Base 16). The hexadecimal representation of 180 is B4:

161
B4

This means we are using 16 eleven times (as B represents 11) and we are using 1 four times.

16 x 11 = 176

1 x 4 = 4

176 + 4 = 180

We can see that B4 is a more succinct way of representing 180 than 10110100. Programming in hexadecimal saves time when compared to using binary instructions.

Here are the values 1-26 represented in decimal, binary and hexadecimal.

DecimalBinaryHexadecimal
00000000000
10000000101
20000001002
30000001103
40000010004
50000010105
60000011006
70000011107
80000100008
90000100109
10000010100A
11000010110B
12000011000C
13000011010D
14000011100E
15000011110F
160001000010
17001000111
180001001012
190001001113
200001010014
210001010115
220001011016
230001011117
240001100018
250001100119
26000110101A

Here we can see an example of the value for 500 in both binary and hexadecimal:

Binary

2561286432168421
111110100

256 + 128 + 64 + 32 + 16 + 4 = 500

Hexadecimal

256161
1F4

F represents 15 in hexadecimal so...

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

An example of a complete binary instruction and the same hexadecimal instruction is shown below:

10110100 00000000 10110000 00010011 11001101 00010000

B4 00 B0 13 CD 10

Hexadecimal code is easier for programmers to work with than machine code.