[algogeeks] Re: Implement division without using divide operator

2007-10-08 Thread Vinay Chilakamarri
How about recursive way: int funcNoDiv(int divisor, int dividend) { //base case if(divisor == dividend) { return 1; } else if( divisor dividend) { return 0; } else // divisor dividend { while(divisor = dividend) { divisor = divisor 1;

[algogeeks] Re: Implement division without using divide operator

2007-10-08 Thread Vinay Chilakamarri
Sorry but lets start with a quotient of 1 On 10/7/07, Vinay Chilakamarri [EMAIL PROTECTED] wrote: How about recursive way: int funcNoDiv(int divisor, int dividend) { //base case if(divisor == dividend) { return 1; } else if( divisor dividend) { return 0; }

[algogeeks] Re: Implement division without using divide operator

2007-10-08 Thread megha
Yes can u please explain the algorithm... On Oct 7, 11:55 pm, Ajinkya Kale [EMAIL PROTECTED] wrote: @Vinay : Can you please explain the algorithm of your code.. On 10/7/07, Vinay Chilakamarri [EMAIL PROTECTED] wrote: How about recursive way: int funcNoDiv(int divisor, int

[algogeeks] Re: Implement division without using divide operator

2007-10-08 Thread Vinay Chilakamarri
hey there i did play around with bit shifting sometime ago and was able to do that.. but yeah i guess the one i posted is a bit different from what i actually did before and is not applicable here. here is what we can do int funcNoDiv(int divisor, int dividend) { if(divisor == dividend) {

[algogeeks] Re: Implement division without using divide operator

2007-10-08 Thread Vinay Chilakamarri
in the previous logic, dont forget to address a negative divisor, dividend and alternative cases like those... it shud be pretty easy On 10/8/07, Vinay Chilakamarri [EMAIL PROTECTED] wrote: hey there i did play around with bit shifting sometime ago and was able to do that.. but yeah i guess