Rather Iffy wrote
But i fail to see how to avoid the multiplication of "2*q" by "y" in the the test "(x-2*q*y) < y" .
I would appreciate some help on this.
I am losing speed in finishing the Jack OS, 2 days by now, alas !
For now, I'd suggest coding it as it's written -- using 2*q*y. That's what I did. Then I came back to it after I got the OS finished.
The aha! insight I had was that q is computed on the way out from the recursive calls. The returned q from the deepest call is always 0, so the 2*q*y from that return is 0 as well.
After divide() returns q to the next level up divide(), it updates q without the need for multiplication -- either q+q or q+q+1 -- and returns q. At the same time, it can update a 'qy2' variable that maintains 2*q*y value that corresponds to q. This update can also be done using just addition.
E-mail me if you want more details,
--Mark