Saving and printing integer values ​​greater than 2 ^ 64

I am trying to write a program for finding prime Mersen numbers. Using the unsigned long long type, I was able to determine the value of the 9th Mersenne prime number, which is (2 ^ 61) -1. For large values, I need a data type that could store integer values ​​greater than 2 ^ 64. Please help. (I should be able to use operators such as: =,>, <, and% with this data type.)

+5
source share
5 answers

You cannot do what you want with C types, but there are libraries that allow you to process arbitrarily large numbers, such as the GNU multipoint arithmetic library .

+6
source

, , :

1) , github, codeflex .. , C.

2) , Python, , Java, BigNum ++.

3) , ( 100 char 100 ) , , , .., ++ . .

+3

, 64- , , . 2 .

, , , ( /, , ).

+2

There is no standard method for a data type exceeding 64 bits. You should check the documentation of your systems, some of them define 128 bits of integers. However, in order to really have flexible integers, you must use a different representation using an array, for example. Then you need to define operators =, <, >etc.

Fortunately, libraries such as GMP allow the use of arbitrary integers.

+1
source

All Articles