Checked multiword subtraction #
Digits use the half-word radix β = 2 ^ (w / 2). A subtraction cell computes
t = β + a - b - c, then returns t % β and borrow 1 - t / β.
For digits a, b < β and incoming borrow c ≤ 1, all intermediate values fit
the physical word, even at width two. In particular, no modular overflow is used.
Main definitions #
Difference.cell: six standard instructions for a digit and outgoing borrow.Difference.program: a fixed-length, in-place multiword difference.
Main results #
Difference.exec_cell: checked execution and the exact borrow equation.Difference.exec: execution and reconstruction of a nonnegative difference.
References #
Arithmetic workspace.
Instances For
Incoming and outgoing borrow.
Instances For
Half-word radix.
Instances For
Preserved one.
Instances For
Subtract one digit and the incoming borrow, replacing the minuend digit.
Instances For
Every cell uses six instructions, with a zero-or-one outgoing borrow and exact reconstruction. The equality accounts for the borrow at both ends.
Execute an entire subtraction, retaining a possible final borrow. Source digits and all registers outside the destinations and arithmetic workspaces are preserved.
Width-only constants, followed by a zero incoming borrow and the unrolled cells.
Instances For
Nonnegative multiword subtraction, with charged constant installation and no preloaded radix or borrow. The running time depends only on the number of digits.