I've been working with arbitrary-precision algorithms lately, and am exceedingly curious how Python goes about it. When I type a very large (600-1000) digits divided by another similarly large number, it just works and I love it. I have the Python source files and am okay with C, which / where in the source is the part that governs this division so I can look at it and maybe tinker with it? My end-game is number theory-type work in C.
The core of the implementation of long / long
in Python 3.3 is in longobject.c
, as the function x_divrem
.
The implementation is modelled after Knuth's "The Art of Computer Programming", Vol. 2 (3rd edition), section 4.3.1, Algorithm D "Division of nonnegative integers", per a comment from the source.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With