What is the fastest algorithm for division of crazy large integers?

后端 未结 2 785
栀梦
栀梦 2020-12-16 01:14

I need to divide numbers represented as digits in byte arrays with non standard amount of bytes. It maybe 5 bytes or 1 GB or more. Division should be done with numbers repre

2条回答
  •  不知归路
    2020-12-16 02:02

    Divide-and-conquer division winds up being a whole lot faster than the schoolbook method for really big integers.

    GMP is a state-of-the-art big-number library. For just about everything, it has several implementations of different algorithms that are each tuned for specific operand sizes.

    Here is GMP's "division algorithms" documentation. The algorithm descriptions are a little bit terse, but they at least give you something to google when you want to know more.

    Brent and Zimmermann's Modern Computer Arithmetic is a good book on the theory and implementation of big-number arithmetic. Probably worth a read if you want to know what's known.

提交回复
热议问题