#separator:tab
#html:true
#notetype:Basic
#tags column:3
#deck:cracked.guide::TAOCP Vol 2::4.3.1 The Classical Algorithms
#columns:Front	Back	Tags
TAOCP §4.3.1 The Classical Algorithms: what does it cover?	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.	cracked.guide cracked.guide::phase::taocp-2 cracked.guide::section::4.3.1 cracked.guide::kind::about
TAOCP §4.3.1: why does it matter?	Every bignum library (Python ints, Java BigInteger, crypto libraries) is built on these. The long division algorithm is notoriously easy to get subtly wrong.	cracked.guide cracked.guide::phase::taocp-2 cracked.guide::section::4.3.1 cracked.guide::kind::why
TAOCP §4.3.1: what traps should you watch for?	<ul><li>Forgetting to normalize the divisor before division.</li><li>Overflow in the quotient-digit estimate.</li><li>Edge cases: divisor with one digit, leading zero digits, dividend smaller than divisor.</li></ul>	cracked.guide cracked.guide::phase::taocp-2 cracked.guide::section::4.3.1 cracked.guide::kind::traps
TAOCP §4.3.1, exercise 6 (rated 22, recommended): what is it asking?	Add left to right without ever revising a digit you have already written.	cracked.guide cracked.guide::phase::taocp-2 cracked.guide::section::4.3.1 cracked.guide::kind::exercise
TAOCP §4.3.1, exercise 16 (rated 20, recommended): what is it asking?	Short division by a single digit. You will use it constantly.	cracked.guide cracked.guide::phase::taocp-2 cracked.guide::section::4.3.1 cracked.guide::kind::exercise
TAOCP §4.3.1, exercise 19 (rated M21, recommended): what is it asking?	The refinement that makes the trial quotient digit almost always correct.	cracked.guide cracked.guide::phase::taocp-2 cracked.guide::section::4.3.1 cracked.guide::kind::exercise
TAOCP §4.3.1, exercise 22 (rated 24, recommended): what is it asking?	Find a case where the rare add-back step is needed. Use it as a test case.	cracked.guide cracked.guide::phase::taocp-2 cracked.guide::section::4.3.1 cracked.guide::kind::exercise
TAOCP §4.3.1, exercise 37 (rated 20, recommended): what is it asking?	Skip normalization when the scale factor is a power of two.	cracked.guide cracked.guide::phase::taocp-2 cracked.guide::section::4.3.1 cracked.guide::kind::exercise
TAOCP §4.3.1, exercise 41 (rated M26, recommended): what is it asking?	Montgomery multiplication for repeated work modulo a fixed number. The basis of fast modular exponentiation.	cracked.guide cracked.guide::phase::taocp-2 cracked.guide::section::4.3.1 cracked.guide::kind::exercise
TAOCP §4.3.1, exercise 43 (rated 22, recommended): what is it asking?	Exact rounded scaling of 8-bit color values without division. A real graphics trick.	cracked.guide cracked.guide::phase::taocp-2 cracked.guide::section::4.3.1 cracked.guide::kind::exercise
TAOCP §4.3.1, exercise 28 (rated M30): what is it asking?	Svoboda's idea for making the divisor easy to divide by. The stretch.	cracked.guide cracked.guide::phase::taocp-2 cracked.guide::section::4.3.1 cracked.guide::kind::exercise
TAOCP §4.3.1: how many exercises, and how are they rated?	43 exercises, rated 10 to 42.	cracked.guide cracked.guide::phase::taocp-2 cracked.guide::section::4.3.1 cracked.guide::kind::exercises
TAOCP §4.3.1: what should you be comfortable with first?	<ul><li>4.1 Positional Number Systems</li></ul>	cracked.guide cracked.guide::phase::taocp-2 cracked.guide::section::4.3.1 cracked.guide::kind::prereqs
TAOCP §4.3.1: how should you work through it?	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.	cracked.guide cracked.guide::phase::taocp-2 cracked.guide::section::4.3.1 cracked.guide::kind::approach
