alright, you got me curious :)
how can you divide without using division ?
I'm not looking for the full code or anything, but just an idea of where you were going.
My guess though there is another way, where you just don't use division, so it's not "divide without division", but rather something else.
Main Topics
Browse All Topics





by: mtmikePosted on 2003-11-04 at 03:47:50ID: 9677855
The straightforward algorithm is to fill the array backwards using modulo and division. For example, in C:
char *itoa(char buffer[12], int i)
{
char *back;
back = buffer + 11;
*back = 0;
do {
*--back = i % 10 + '0';
i /= 10;
} while (i);
return back;
}
In assembly, the IDIV instruction computes both quotient and remainder. You can also avoid using division entirely, but that's more difficult.