I develop software for embedded platform and need a single-word division algorithm.
The problem is as follows:
given a large integer represented by a sequence of 32-bit words (can be many),
we need to divide it by another 32-bit word, i.e. compute the quotient (also large integer)
and the remainder (32-bits).
Certainly, If I were developing this algorithm on x86, I could simply take GNU MP
but this library is way too large for embdedde platform. Furthermore, our processor
does not have hardware integer divider (integer division is performed in the software).
However the processor has quite fast FPU, so the trick is to use floating-point arithmetic wherever possible.
Any ideas how to implement this ?
Take a look at this one: the algorithm divides an integer a[0..n-1] by a single word ‘c’
using floating-point for 64×32->32 division. The limbs of the quotient ‘q’ are just printed in a loop, you can save then in an array if you like. Note that you don’t need GMP to run the algorithm – I use it just to compare the results.