Hello, I'm writing algorithms for large numbers. I implemented the addition, division and subtraction operations but for the divide I have no idea just an algorithm to use with binary basis. It is not an option to turn the number to binary, I want to use base 10.
The numbers I want to divide are represented as follows:
2346
| 2 | - | 3 | -> 4 | -> 6 |
It's a circular list.
How can I do this?
I will leave the algorithm in binary recursive for the division:
funcao divide(x,y)
entrada: dois numeros inteiros de n bits x e y, onde y >= 1
saida: o quociente e o resto de x dividido por y
se x = 0 : retorn (q,r) = (0,0)
(q,r) = divide(floor(x/2),y)
q = 2*q, r = 2*r
se x é impar: r = r + 1
se r>=y: r = r - y, q = q + 1
retorna (q,r)