# 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:

Decimal | Hexadecimal |

0 | 0 |

1 | 1 |

2 | 2 |

3 | 3 |

... | ... |

8 | 8 |

9 | 9 |

10 | A |

11 | B |

12 | C |

13 | D |

14 | E |

15 | F |

16 | 10 |

17 | 11 |

18 | 12 |

19 | 13 |

... | ... |

24 | 18 |

25 | 19 |

26 | 1A |

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.

Hex | Decimal | Hex | Decimal |

00 | 0 | 00 | 0 |

01 | 1 | 10 | 16 |

02 | 2 | 20 | 32 |

03 | 3 | 30 | 48 |

04 | 4 | 40 | 64 |

05 | 5 | 50 | 80 |

06 | 6 | 60 | 96 |

07 | 7 | 70 | 112 |

08 | 8 | 80 | 128 |

09 | 9 | 90 | 144 |

0A | 10 | A0 | 160 |

0B | 11 | B0 | 176 |

0C | 12 | C0 | 192 |

0D | 13 | D0 | 208 |

0E | 14 | E0 | 224 |

0F | 15 | F0 | 240 |

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:

Nibbles | Bytes |

Hex | Decimal | Hex | Decimal |

00 | 0 | 00 | 0 |

01 | 1 | 10 | 16 |

02 | 2 | 20 | 32 |

03 | 3 | 30 | 48 |

04 | 4 | 40 | 64 |

05 | 5 | 50 | 80 |

06 | 6 | 60 | 96 |

07 | 7 | 70 | 112 |

08 | -8 | 80 | -128 |

09 | -7 | 90 | -112 |

0A | -6 | A0 | -96 |

0B | -5 | B0 | -80 |

0C | -4 | C0 | -64 |

0D | -3 | D0 | -48 |

0E | -2 | E0 | -32 |

0F | -1 | F0 | -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•.