Wiki says this following algorithm is a version of long division. Does anyone know mathematically what is happening R is being left shifted, then the least significant bit of R(0) is set to the N(i)?
I know the left shift is 2R, but I'm a little lost after that.
if D = 0 then error(DivisionByZeroException) end
Q := 0 -- Initialize quotient and remainder to zero
R := 0
for i := n − 1 .. 0 do -- Where n is number of bits in N
R := R << 1 -- Left-shift R by 1 bit
R(0) := N(i) -- Set the least-significant bit of R equal to bit i of the numerator
if R ≥ D then
R := R − D
Q(i) := 1
end
end