# TAOCP 4.3.1 The Classical Algorithms

> Study guide to TAOCP 4.3.1 The Classical Algorithms. Grade-school arithmetic on arbitrarily long integers: addition, subtraction, multiplication and…

Updated October 20, 2026.

## Summary {#summary}

TAOCP 4.3.1 The Classical Algorithms: Grade-school arithmetic on arbitrarily long integers: addition, subtraction, multiplication and especially long division, where Knuth gives a careful algorithm for estimating each quotient digit and proves it is almost always right. Budget about 10 hours; do exercises 6, 16 and 19.

## Key facts {#key-facts}

- Week 78 of 145 on the cracked.guide path, in [TAOCP Vol 2: Seminumerical Algorithms](https://cracked.guide/taocp/volume-2).
- Time budget: about 10 hours.
- 43 exercises in the section, rated 10 to 42; the guide picks 8.
- Picked exercises with Knuth's triangle for recommended: 6, 16, 19, 22, 37, 41 and 43.
- Before you start: 4.1 Positional Number Systems.

## Week 78 goals {#objectives}

By the end of week 78 you can:

- Implement multiple-precision addition, subtraction and multiplication on digit arrays.
- Explain why normalizing the divisor makes the quotient estimate nearly right.
- Trace long division with Algorithm D on a small example.

## This week's steps {#steps}

- Read §4.3.1 The Classical Algorithms: Implement all four operations for numbers stored as arrays of 32-bit digits in C, with 64-bit intermediates.
- Work the exercises (8 picked): Start with Ex 6, Ex 16, Ex 19; log what you solve below.
- Write down one thing you'd explain to someone: A few sentences in your own words in Your notes: the idea, why it works, an example. 30 words ticks this.

## Exercises {#exercises}

This section has 43 exercises, rated 10 to 42, and Knuth marks 11 of them with the triangle for recommended. Implement Algorithms A, S, M and D in a real language with a small radix so you can test against built-in big integers; most picks are about getting long division exactly right.

Worth your time:

- 6 (rated 22, recommended): Add left to right without ever revising a digit you have already written.
- 16 (rated 20, recommended): Short division by a single digit. You will use it constantly.
- 19 (rated M21, recommended): The refinement that makes the trial quotient digit almost always correct.
- 22 (rated 24, recommended): Find a case where the rare add-back step is needed. Use it as a test case.
- 37 (rated 20, recommended): Skip normalization when the scale factor is a power of two.
- 41 (rated M26, recommended): Montgomery multiplication for repeated work modulo a fixed number. The basis of fast modular exponentiation.
- 43 (rated 22, recommended): Exact rounded scaling of 8-bit color values without division. A real graphics trick.
- 28 (rated M30): Svoboda's idea for making the divisor easy to divide by. The stretch.

## Why it matters {#why}

Every bignum library (Python ints, Java BigInteger, crypto libraries) is built on these. The long division algorithm is notoriously easy to get subtly wrong.

## Before you start {#before}

- 4.1 Positional Number Systems

## How to approach it {#approach}

Implement all four operations for numbers stored as arrays of 32-bit digits in C, with 64-bit intermediates. Test against Python's integers on random inputs. Spend most of the time on division and its normalization step.

## Common traps {#traps}

- Forgetting to normalize the divisor before division.
- Overflow in the quotient-digit estimate.
- Edge cases: divisor with one digit, leading zero digits, dividend smaller than divisor.

## Links {#links}

- [Knuth's TAOCP page (editions, errata, MIX/MMIX)](https://www-cs-faculty.stanford.edu/~knuth/taocp.html)
- [Vol 2 errata (plain text, from Knuth)](https://www-cs-faculty.stanford.edu/~knuth/err2.textxt)
- [Wikipedia: Arbitrary-precision arithmetic](https://en.wikipedia.org/wiki/Arbitrary-precision_arithmetic)
- [Wikipedia: Long division](https://en.wikipedia.org/wiki/Long_division)
- [Hacker News: A decades-old bug in Knuth's long division (TAOCP Vol II, Algorithm 4.3.1D)](https://news.ycombinator.com/item?id=49286258)

---

Source: https://cracked.guide/guide/knuth-w061-0
cracked.guide: A free, dated 145-week path to getting genuinely cracked at programming.
