Appendix D - Hexadecimal conversion

The hexadecimal is widely used in the field of computers, but decimal is easier for the human to understand. Hexadecimal is based on the number 16, just as in the same way that decimal is based on the number 10. There are not 16 single digit numbers, so we are forced to use the first 6 letters of the alphabet as well as the 10 numbers to represent a hexadecimal digit. The first few numbers run:

DecimalHexadecimal
00
11
22
33
......
88
99
10A
11B
12C
13D
14E
15F
1610
1711
1812
1913
......
2418
2519
261A

and so on. The easiest way of converting hexadecimal to decimal is to split up the digits into single units, and then add up. We prefix hexadecimal numbers with the sign ”&•, and we also abbreviate it to ”hex•.

In decimal, we can think of the number 157 as being 100 + 50 + 7. The same is true for hexadecimal. The hexadecimal number &B8 is &B0 + &08, so to convert a two digit hexadecimal number to a decimal number, you only need to know the first 16 digits.

HexDecimalHexDecimal
000000
0111016
0222032
0333048
0444064
0555080
0666096
07770112
08880128
09990144
0A10A0160
0B11B0176
0C12C0192
0D13D0208
0E14E0224
0F15F0240

So, in the above example, &B8 is &B0 + &08, which is 176 + 8, which is 184. Similarly, &EF is &E0 + &0F, which is 224 + 15, which is 239.

Signed conversion

Some of the effects require signed nibbles, or bytes. If this is the case, then the following conversion numbers are useful:

NibblesBytes
HexDecimalHexDecimal
000000
0111016
0222032
0333048
0444064
0555080
0666096
07770112
08-880-128
09-790-112
0A-6A0-96
0B-5B0-80
0C-4C0-64
0D-3D0-48
0E-2E0-32
0F-1F0-16

So, if you had to convert &EA into signed decimal, it is &E0 + &0A, which is -32+10, or -22. The largest number you can have is &7F, or 127, the lowest is &80, or 128. Similarly, for a two signed nibbles, the value &2F would mean the two values •2•, and ”-1•.