Link to home
Start Free TrialLog in
Avatar of angelos-constantinides
angelos-constantinidesFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Binary Division with remainder

I need a function that takes as input 2 strings 1 is divident and 2 is the divisor i need this function to return me the remainder of this division string represent binary numbers with regular expression (0|1)* the quotient must be returned via pointer
i want this function to return a string as well

for example    char *binremainder(char *divident,char *divisor,char *quotient);

Language Interface Required is ANSI C.

ASAP

thnx in advance
Avatar of Infinity08
Infinity08
Flag of Belgium image

Is there any reason you're using a string of binary digits ? It would be a lot simpler to use an integer type.

Which is what I'd suggest too : convert the strings to ints, perform an int modulo, and convert the result back to a string.
The alternative is to implement the binary division yourself :

        http://en.wikipedia.org/wiki/Binary_numeral_system#Division

(the same way you perform a long (decimal) division)
Avatar of angelos-constantinides

ASKER

The reason I need in string is because it is required by the rest source code converting it to integers is not an option because the exceed the limitations of C language

trying to convert to integer will result in a number greater that max int.

ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
>> trying to convert to integer will result in a number greater that max int.

Ok, then go with my second suggestion :)