If you save the value (128 bits) using the maximum possible native representation that your architecture can process (64-bit), you will have problems processing the intermediate division results (as you already found :)).
But you can always use the SMALLER view. How about FOUR 32-bit numbers? Thus, you can use your own 64-bit operations without overflow problems.
A simple implementation (in Delphi) can be found here .
FDCastel Dec 09 '09 at 23:38 2009-12-09 23:38
source share