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

后端 未结 2 784
栀梦
栀梦 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 01:56

    The standard long division algorithm, which is similar to grade school long division is Algorithm D described in Knuth 4.3.1. Knuth has an extensive discussion of division in that section of his book. The upshot of this that there are faster methods than Algorithm D but they are not a whole lot faster and they are a lot more complicated than Algorithm D.

    If you determined to get the fastest possible algorithm, you can resort to what is known as the SRT algorithm.

    All of this and more is covered by the way on the Wikipedia Division Algorithm.

提交回复
热议问题