@Radha: You could simulate long division. It would look something like this:
int divide(int a, int b) { int i, k=0, q=0, s=1; // error checking if( b == 0 ) return 0 // return 0 for division by zero // handle signs if( a < 0 ) { a = -a; s = -1; } if( b < 0 ) { b = -b; s = -s; } // quick cases if( a < b ) return 0; if( a == b ) return s; // shift divisor to align with dividend while( b < a ) { b <<= 1; ++k; } // perform k steps of long division in binary for( i = 0 ; i < k ; ++i ) { q <<= 1; b >>= 1; if( a > b ) { a -= b; q |= 1; } } // apply sign to result if( s < 0 ) q = -q; return q; } Dave On Aug 18, 8:56 am, radha krishnan <radhakrishnance...@gmail.com> wrote: > how to do using BIT manipulation ? -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.