Framed reading 30 minutes + canonical resource

Number Systems and Boolean Algebra: The Two Ideas Under Everything

Hook #

Every value your programs have ever touched — an integer, a string, a floating-point price, a JSON blob, this sentence — was, at the bottom, a pattern of high and low voltages on wires. And every operation you've ever run — an addition, a comparison, a hash, a branch — was, at the bottom, a network of gates that each do one dumb thing to those voltages. This course is where you go all the way down and then build all the way back up. Two ideas hold the whole floor: binary, the way numbers become voltage patterns, and Boolean algebra, the way logic becomes circuits. Everything above them — the ALU, the CPU, the operating system, your Rails app — is a very tall stack of consequences of these two ideas.

What you'll be able to do by the end of this lesson #

  • Convert fluently between binary, hexadecimal, and decimal, and explain why hex exists at all (it's not a third number system you have to care about — it's a shorthand for binary).
  • Explain two's complement well enough to say why -1 is 1111...1 and why there's one more negative number than positive.
  • State the three basic Boolean operations (AND, OR, NOT) as both truth tables and gate symbols, and recognise them as the same propositional logic you met in Course 1.1.
  • Explain why NAND is called "universal" and what that claim actually buys you.

A quick try before we start #

Without looking anything up: what is 1010 in binary, as a decimal number? Now, what is 0xFF in decimal? If you got 10 and 255, you already have the mechanical skill — this lesson is about the why underneath it. If you didn't, that's exactly what the Nand2Tetris chapter will fix in twenty minutes; come back to this framing after.

Why this matters here #

You have spent your whole career on the far side of an abstraction that says "a number is a number." Here the abstraction dissolves. A 32-bit int is literally 32 wires; an overflow is literally a carry that fell off the end of the last wire. Once you've seen that, a whole class of bugs stops being mysterious: integer overflow, the 0.1 + 0.2 != 0.3 float surprise, why bit-shifting is multiplication by two, why bitmasks and flags work the way they do. None of it is trivia after this course — it's the machine showing through.

This is also lesson one of a course with an unusual shape. The Nand2Tetris project builds a working computer starting from a single gate. Boolean algebra is the mathematics of that first gate. Combinational circuits (lesson 2) are what you build out of gates with no memory; sequential circuits (lesson 3) add memory; the CPU (lesson 4) is those two combined and orchestrated; caches (lesson 5) are the first crack in the "memory is uniform" lie. Each lesson is one layer up. This one is the ground.

The engineer's lens #

Here's the connection no gate diagram will draw for you: Boolean algebra is propositional logic from Course 1.1, wearing an electrical engineer's hat. The AND you truth-tabled to reason about proofs is the same AND that's a gate with two input wires and one output wire. p ∧ q and "output is high only when both inputs are high" are the same statement. De Morgan's laws — which you proved as a logic identity — are the reason a hardware designer can replace an OR-of-NOTs with a NAND and save transistors. The math you did on paper for reasoning is the math the silicon runs on. That is not a metaphor; it's an identity.

And two's complement is the quiet piece of genius most people use for years without noticing. The naive way to represent negative numbers would be a sign bit — but then you have two zeros (+0 and -0) and your adder needs special cases for signs. Two's complement is chosen precisely so that the same addition circuit works for signed and unsigned numbers with no modification. 5 + (-3) and 5 + 253 (unsigned) are the identical wire-level operation; the bits don't know or care which interpretation you meant. That's why it won. When you later see why x & (x-1) clears the lowest set bit, or why hashing code leans on XOR, you're cashing in this lesson.

What to focus on in Nand2Tetris Chapter 1 #

  • The NAND-is-universal argument. This is the load-bearing idea of the whole book. Convince yourself you can build NOT, AND, OR, XOR, and a multiplexer using nothing but NAND gates. Don't just read it — the exercise lesson has you build them in the HDL, and that's where it lands.
  • Truth tables → gate → HDL. Watch how the same logic appears three ways (a table, a circuit symbol, a line of HDL). Fluency here is moving between the three without friction.
  • Skip on first pass: the deeper HDL syntax details and the Nand implementation internals. You're using NAND as a primitive this chapter, not implementing it from transistors — that's a physics course, not this one.
  • Slow down on the multiplexer. A mux ("if sel then b else a") is the single most important gate you'll build. It's how hardware does an if. You'll see it everywhere in lessons 2 and 4.

Explain it back #

In your own words, to a colleague who writes application code and has never thought below the int: explain why hexadecimal exists. The answer isn't "it's base 16" — that's what it is, not why anyone bothered. The right answer connects hex to binary specifically (one hex digit = exactly four bits), and says what problem that shorthand solves for a human reading a memory dump.

Where this connects #

Backward: Course 1.1's propositional logic and truth tables. You built the reasoning tool there; here you learn it was also a circuit-design tool the whole time. De Morgan's laws, in particular, come back as a hardware optimisation.

Forward: Lesson 2 takes these gates and wires them into things that compute — adders, multiplexers, and finally an ALU, the arithmetic heart of the CPU. Everything in lesson 2 is "combinational": output depends only on the current inputs, with no memory. Memory arrives in lesson 3, and that's when a pile of gates becomes something that can hold state and, eventually, run a program.

That's the free preview. Sign in to continue this course.

Sign in to continue

New here? Make a desk →