2016-04-30 327 views
5

integer的大小是4,long long int是8字節,它可以訪問大約19位數據,而對於無符號long long int大小也是8字節,比long long int大,但小於20位。有什麼辦法可以處理超過20位的數據。如何處理大於8字節或超過20位數字的大整數數據在C++中

#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; 
    } 
} 

我搜索一下了一段時間,但並沒有找到有用的contents.All的是java的biginteger

+0

[GMP](https://en.wikipedia.org/wiki/GNU_Multiple_Precision_Arithmetic_Library)可以是利益。 –

回答

3

C++中沒有大於unsigned long long的內置類型。

你有2種選擇:

  • 使用支持 「BigInts」(例如gmp
  • 實現自己的 「BigInt有」 一流的圖書館