Storing and printing integer values greater than 2^64

后端 未结 5 437
粉色の甜心
粉色の甜心 2020-12-06 12:17

I am trying to write a program for finding mersenne prime numbers. Using the unsigned long long type I was able to determine the value of the 9th mersenne prime, which is (2

5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-06 12:36

    To store large numbers, there are many choices, which are given below in order of decreasing preferences:

    1) Use third-party libraries developed by others on github, codeflex etc for your mentioned language, that is, C.

    2) Switch to other languages like Python which has in-built large number processing capabilities, Java, which supports BigNum, or C++.

    3) Develop your own data structures, may be in terms of strings (where 100 char length could refer to 100 decimal digits) with its custom operations like addition, subtraction, multiplication etc, just like complex number library in C++ were developed in this way. This choice could be meant for your research and educational purpose.

提交回复
热议问题