Binary division of large numbers
As a newbie to this forum can I first say that I'm far from an expert programmer. I write in C using gcc on a Linux machine, and I'm always surprised when something actually works! Please could anyone help me with a problem I can't see any way to resolve?
I am trying to make an encoder for OneCode, the new 4-state barcode system used by the USPS. Once done it will form part of my larger barcode encoding project at (http://rjstuart.pwp.blueyonder.co.uk/zint).
Following the instructions on the USPS website I have got as far as the correct calculation of a 102-digit binary number which I have stored in a short int array (not the best use of memory, but it works). In order to get this far I have already written functions which handle binary addition, subtraction and multiplication. The next step is that I need to divide. As an example (in hex):
016907B2A24ABC16A2E5C004B1 divided by 27C.
I will need both the quotient and the remainder. I have written code that will recursively take away until I get a negative number, and from it I can get the correct values, but it takes forever to do the calculation this way. I've looked at the 'long division' method of binary division but can't figure out how to put it into code.
I'm sure there must be a quicker way, but how?
Thank you for any suggestions.