TAOCP Vol 2: Seminumerical Algorithms · Week 57

TAOCP 4.1 Positional Number Systems: reading guide

About the book

Number representations: binary, octal, hex, and exotic systems like negative bases, balanced ternary, and mixed radix. Knuth also covers a little history of how positional notation developed.

Time About 5 hours this week

Why it matters

Bit manipulation, encodings and serialization formats all depend on fluent radix thinking. Mixed radix is how you convert time units and index multi-dimensional arrays.

Before you start

  • 1.2.4 Integer Functions

How to approach it

Convert a few numbers to base -2 and balanced ternary by hand. Write a function that converts to any mixed radix.

Exercises

Do every exercise rated 00 to 20 in your head or on paper; they are quick and they check you actually absorbed the definitions. Then pick two or three rated 20 to 25 (M or not) and grind them out fully. Attempt one M25 to M30 and give yourself a hard 90-minute cap before reading the answer. Always read the answer to every exercise you attempted, even the ones you got, because Knuth's answers often teach a second technique.

Traps

  • Rushing through the negative-base examples. They are fun and they check your understanding.

Links

Back to week 57