Hacker’s Delight (Henry S. Warren Jr.)
The canonical textbook of bit manipulation — Henry S. (“Hank”) Warren Jr. (IBM research fellow), Addison-Wesley: 1st ed. 2002 (306 pp), 2nd ed. 2013 (494 pp), foreword by Guy L. Steele. The reference the spoke’s other sources (bit-twiddling-hacks, count-set-bits-so, Stephan Brumme’s bits) repeatedly cite as the authority — and the open-question gap the spoke flagged at spin-out, now closed.
What it covers
Fast bit-level and low-level arithmetic algorithms for common tasks. Across ~12 chapters: integer overflow, counting and rearranging bits/bytes (the population-count family), extracting bits under a mask, permuting bits, multiplying bit matrices, multiword arithmetic, and the famous division/remainder by constants via multiply-and-shift (turning a slow divide into a multiply — the trick compilers now emit automatically). Examples are in C and RISC assembler (a PowerPC-like ISA), with algorithms given as formulas for any word width (examples usually 32-bit). Target audience, per Steele’s foreword: compiler writers and high-performance-code authors.
Why it grounds the spoke
This is the field’s foundational text, so it anchors several of this wiki’s threads at their source:
- It is the T1 primary behind bit-manipulation, population-count, and branchless-programming — the formal treatment of the tricks the web sources present as snippets.
- Its division-by-constants-via-multiply material is the deepest example of the spoke’s recurring lesson (branchless-programming): a hand-derived bit/arithmetic trick that compilers now generate for you — Hacker’s Delight is where many of those compiler optimizations were first written down, which reframes “the compiler wins now” as “the compiler absorbed Hacker’s Delight.”
- Algorithms stated as width-general formulas (not 32-bit-specific hacks) give the spoke its most rigorous register — the bridge from copy-paste snippets to derivable method.
Tier
T1 — the authoritative primary reference for the field (peer-regarded, foreword by Guy Steele). Provenance note: this page summarizes the book’s scope from secondary sources (Wikipedia / publisher / the foreword), not a full reading; specific in-book derivations are not quoted.
Related
bit-manipulation · population-count · branchless-programming · bit-twiddling-hacks · count-set-bits-so