Division algorithm help, please

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Division algorithm help, please

code2win
Division
I get that it keeps calling itself until y exceeds x, at which point it returns 0, which becomes Q for the previous call.
Then the if statement asks if X-2 * Q--zero in this case--times Y is less than Y (0 * y is 0); and 0 IS less than Y, and thus 2 * Q (0) is returned to the previous call, which becomes its Q, and the cycle repeats with 0 endlessly. Can someone help me see how this results in anything but 0?
Reply | Threaded
Open this post in threaded view
|

Re: Division algorithm help, please

code2win
Oh, it's pseudo-code, so it DOES follow operator precedence? Grrrrrrr....
So it's X minus 0, which is not less than Y, and thus returns 1 to Q. Okay.