Division with really big numbers

后端 未结 3 1488
终归单人心
终归单人心 2021-01-23 10:50

I was just wondering what different strategies there are for division when dealing with big numbers. By big numbers, I mean ~50 digit numbers .

e.g. 9237639100273856744

3条回答
  •  别那么骄傲
    2021-01-23 11:39

    What language / platform do you use? This is most likely already solved, so you don't need to implement it from scratch. E.g. Haskell has the Integer type, Java the java.math.BigInteger class, .NET the System.Numerics.BigInteger structure, etc.

    If your question is really a theoretical one, I suggest you read Knuth, The Art of Computer Programming, Volume 2, Section 4.3.1. What you are looking for is called "Algorithm D" there. Here is a C implementation of that algorithm along with a short explanation: http://hackers-delight.org.ua/059.htm

提交回复
热议问题