modulo 2 division question help

Would anyone know how to write a program that does binary division (modulo 2) for example, take the number 10110010 which is a binary number, and divides it by 1011 which is also a binary number, then see the remainder.

this is what i have so far, it works fine for normail integer division e.g 23 / 7

but it wont work for binary modulo 2 division

thanks in advance

Code:

`int posndiv(int divdend, int divisor)`

{

int quotient;

int bit_position =1;

if (dividend <=0) {

quotient = -1; /* error cond.: return -1 */

} else if(divisor <= 0) {

quotient = -1; /* error cond.: return -1*/

} else {

quotient = 0;

while ((dividend > divisor) && !(divisor & 0x80000000)){

divisor = divisor << 1;

bit_position = bit_position << 1;

}

while (bit_position > 0) {

if (dividend >= divisor) {

dividend = dividend - divisor;

quotient = quotient + bit_posiition;

}

divisor = divisor >> 1;

bit_position = bit_position >> 1;

}

}

return quotient; // quotient = dividend/divisor

}

Re: modulo 2 division question help

Kudo's for using code tags on your first post!! Unfortunately to get the most out of code tags, you must format your code so it's readable. Try indenting your blocks with spaces.