Division with really big numbers

后端 未结 3 1497
终归单人心
终归单人心 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:30

    if you don't need very exact result, you can use logarithms and exponents. Exponent is the function f(x)=e^x, where e is a mathmaticall constant equal to 2.71828182845...
    Logarithm (marked by ln) is the inverse of the exponent.

    Since ln(a/b)=ln(a)-ln(b), to calculate a/b you need to:
    Calculate ln(a) and ln(b) [By library function, logarithm table or other methods]
    substruct them: temp=ln(a)-lb(b)
    calculate the exponent e^temp

提交回复
热议问题