The existing binary long-division word algorithm #
The public step, quotient/remainder laws and prefix encoding bound are moved unchanged from the higher division facade, independently of any higher computability calculus.
One shift-and-subtract step of binary long division with divisor b, state (q, r), and next
most-significant dividend bit bit. When b = 0, the quotient remains 0 and the remainder
accumulates the binary value of the dividend.
Instances For
theorem Turing.MultiTapeTM.BinaryDiv.foldl_divModStep (b : ℕ) (word : List Bool) :
List.foldl (divModStep b) (0, 0) word = (Cslib.BitString.binaryValue word / b, Cslib.BitString.binaryValue word % b)
Folding divModStep over any most-significant-first bit word computes the quotient and
remainder of Cslib.BitString.binaryValue word by b.
Folding divModStep over the reversed binary digits of p.1 computes
(p.1 / p.2, p.1 % p.2).