CHAPTER 7 · 2 lessons · 26 exercises

Numbers and logic

Binary, hexadecimal, complements and logic operations. The shape a number takes inside a computer.

This chapter gathers up why the #ff0000 you have been writing in CSS is hexadecimal, why file sizes are in bytes, and why one of those bytes is eight bits.

Moving between binary and hexadecimal, how negative numbers are written (complements), the bitwise AND, OR and XOR, character codes, and the error in floating point. This is where "why does 0.1 + 0.2 come out as 0.30000000000000004" gets an answer.

It sits late in the course because nothing here is needed to make something run, while it explains a great many things once you know it. In the exam it is the very first field, so do not be thrown by the difference in order.

Lessons in this chapter

Binary and hexadecimal

  1. 15Binary and hexadecimalA machine has nothing but 0 and 1. From there, follow the trail to the #ff0000 of colours and to why 0.1 + 0.2 will not come out evenly.Go to the exercises

Logic operations and character codes

  1. 16Bit logic and character codesThe four operations that compare bits one place at a time. Masks that pull out just the places you want, shifts that move places along, and the machinery for finding a single broken bit.Go to the exercises

Next up is “How a computer works”. The CPU, memory, and the layers of storage. How the fast parts and the slow parts get along.