Big number in C++

后端 未结 9 1551
暖寄归人
暖寄归人 2020-12-16 19:13

I am trying to place a big number in a C++ variable. The number is 600851475143

I tried unsigned long long int but got an error saying it the constant was too big.

9条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-16 19:59

    You can specify an integer literal as long by the suffix L.
    You can specify an integer literal as long long by the suffix LL.

    #include 
    
    int main()
    {
        long long num = 600851475143LL;
    
        std::cout << num;
    }
    

提交回复
热议问题