Which data type to use for a very large numbers in C++?

后端 未结 3 639
悲&欢浪女
悲&欢浪女 2021-02-08 14:21

I have to store the number 600851475143 in my program. I tried to store it in long long int variable and long double as well but on compil

3条回答
  •  时光取名叫无心
    2021-02-08 15:18

    You had the right idea with long long int (or unsigned long long int), but to prevent the warning, you need to tell the compiler that the constant is a long long int:

    long long int value = 600851475143LL;
    

    Those "L"s can be lower-case, but I'd advise against it -- depending on the font, a lower-case "L" often looks a lot like a one digit ("1") instead.

提交回复
热议问题