I am trying to implement Long division algorithm.
But I faced some problems.

If we take N=1100 and D=100
Step 1: Set R=0 and Q=0 Step 2: Take i=3 (one less than the number of bits in N) Step 3: R=00 (left shifted by 1) Step 4: R=01 (setting R(0) to N(i))
how did we get '01' on fourth step, if n[3] = 0 from N = 1100
I tried to code program, but I can't understand the fourth step.
n = "1100";
d = "0100";
let q = "0";
let r = "0";
for (let i = 3; i >= 0; i--) {
r = r + "0"; //0 + 0 = "00"
r[0] = n[i];
if (r >= d) {
r = String(r - d);
q[i] = 1;
}
}
console.log(q);
console.log(r);
We use Q as result of '1' but if result of division is '101' where did we take '0' from r?