Big number in C++

后端 未结 9 1537
暖寄归人
暖寄归人 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 20:06

    The first thing to do in this case is to figure out what is the largest number that you can fit into an unsigned long long. Since it is 64 bit, the largest number would be 2^64-1 = 18446744073709551615, which is larger than your number. Then you know that you are doing something wrong, and you look at the answer by Martin York to see how to fix it.

提交回复
热议问题