A sign is one bit

You will learn

How a signed multiply sets the sign of its product, and which test notices when it never does.

Modules 1 to 4 were about storing numbers: the T27 cell, the OCP MX scale byte, ternary weights scaled by phi, and TNF; this module makes them do arithmetic. gft_smul.t27 uses the bits of tnf17.t27: 1.0 is 20480, and -1.0 is 86016, the same bits plus the sign bit 65536. smul sets the sign when the two input signs differ and leaves the size to magmul. The browser skips all 3 tests because its runner does not know assert_eq yet; the native t27c runs all 3, all pass, none vacuous. The recording runs t27c test-report, then a one-line sed that makes the sign always 0, and t27c test-report again: exactly one test fails, m2, which multiplies 1.0 by -1.0. git checkout puts the line back, and sha256sum prints the same hash as before the edit. Every byte in the recording was printed by the command; only the typing is staged.

Open the interactive lesson →