3 ms·
If you're interested in learning more: * Check out libdivide: http://libdivide.com/ http://libdivide.com/ * Also, the awesome book "Hacker's Delight" has extens
by bodyfour 10y ago
If you're interested in learning more:
* Check out libdivide: http://libdivide.com/ http://libdivide.com/
* Also, the awesome book "Hacker's Delight" has extensive information about how and why these tricks work. It's the bit-twiddling bible -- probably my favorite programming book I've ever read
- csl 10y agoThere seems to be a preprint on that chapter from here: http://www.hackersdelight.org/divcMore.pdf http://www.hackersdelight.org/divcMore.pdf I recommend the book as well, it's got a lot of really awesome tricks!
- torrent-of-ions 10y agoThat's very cool... Some years ago I wrote my own multiple-precision arithmetic library. I implemented a lot of it in assembly so that I could access the carry bit and do full-word multiplication etc. I studied GMP and realised that my addition and subtraction were near enough perfect, but multiplication and division were far off. I now see that just because I was way off with division because I simply implemented the long division algorithm and used IDIV for words (and even that was more difficult than the other algorithms).