How to handle large integer data of more than 8 bytes or more than 20 digits in C ++

integer size is 4, long long int is 8 bytes, and it can access 19-digit data, and for unsigned long long int size it is also 8 bytes, but handle a larger value than long long int, but it is less than 20 digits. Is there a way that can handle more than 20 digits of data.

 #include<iostream> using namespace std; int main() { unsigned long long int a;//any data type more than 8 byte can handle cin>>a; if(a>789456123789456123123)//want to take a higher thand this digits { cout<<"a is larger and big data"<<endl; } } 

I searched for this for a while, but did not find any useful content. All about java biginteger .

+5
source share
2 answers

you can use the library to implement it. many libraries are available. eg:

Gmplib

bigint

See details

Arbitrary-precision_arithmetic # Libraries

+1
source

There are no built-in types in C ++ that exceed unsigned long long .

You have 2 options:

  • Use a library that supports "BigInts" (like gmp )
  • Deploy Your Own BigInt Class
+3
source

All Articles