Exercises

Here are some exercises that you can use to check your understanding of the binary and hexadecimal number systems.[27] I've limited the examples to addition and subtraction, as that is all that you're ever likely to have to do in these number systems. These operations are exactly like their equivalents in the decimal system, except that as we have already seen, the hexadecimal system has six extra digits after 9: a, b, c, d, e, and f. We have to take these into account in our calculations: for example, adding 9 and 5, rather than producing 14, produces e.

[27] Please note that the ability to do binary or hexadecimal arithmetic is not essential to further reading in this book.

  1. Using the hexadecimal system, answer these problems:

    1. 1a + 2e ...

Get Learning to Program in C++ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.