Converting an arbitrary large number to base 256

前端 未结 1 899
旧时难觅i
旧时难觅i 2021-01-22 06:36

I have a number of very large length may be upto 50 digits. I am taking that as string input. However, I need to perform operations on it. So, I need to convert them to a proper

1条回答
  •  一生所求
    2021-01-22 07:14

    Multiple-precision arithmetic (a.k.a. bignums) is a difficult subject, and the good algorithms are non intuitive (there are books about that).

    There exist several libraries handling bignums, like e.g. the GMP library (and there are other ones). And most of them take profit from some hardware instructions (e.g. add with carry) with carefully tuned small chunks of assembler code. So they perform better than what you would be able to code in a couple of months.

    I strongly recommend using existing bignum libraries. Writing your own would take you years of work, if you want it to be competitive.

    See also answers to this question.

    0 讨论(0)
提交回复
热议问题