I've been trying to take Henry Warren's division algorithm in C, and code it in Pascal.
Here's a web page that discusses the C code, and variations of it...
https://skanthak.homepage.t-online.de/division.htmlI have made much progress, but I'm still having problems. My head is starting to spin, because my Pascal code is behaving differently to how I imagine the C code should work, in ways I don't understand. In some parts of the code, I cannot make sense of what the C code is trying to do, so have no idea what is going wrong.
Is there anyone out there who is interested in debugging extremely complex algorithms, who would be interested helping me crack this problem?
If I can get it working, I'm going to use it in my Pascal big integer library, instead of my own mediocre division algorithm I'm currently using. Once the library/unit is finished & tested, I intend to contribute it to the Free Pascal community.
Thanks.
PS...
1. there is a variation of the algorithm in the Free Pascal RTL, but it is too specialized for me to use easily.
2. I advise caution if taking the C code directly from the above web site, it is different to the code in the "Hacker's Delight" book I am working from.
3. You could argue that if I cannot solve/crack this problem myself, then I am being too ambitious in trying to create a big integer library! And I would struggle to argue against that!
4. Oh, how I hate C! This problem exemplifies everything I hate about that abominable language! It creates the illusion of a safe, high-level language, but in reality it is just bit of superficial gloss on top of an assembly language. Almost every security bug in Unix/Linux over the last 30 years can be directly attributed to bad design of the C language and its run-time libraries.