My C++ programme may create a value until 10^16 during the run time, I tried to use "long long int" for it but it didn't work. Which data type correspond to 10^16?
Thanks;
The minimum guaranteed maximum of long long int
is 2^63 - 1
, which is approximately 10^19
. It should be fine. To be sure, use the std::int_least64_t
type from <cstdint>
. It is guaranteed to have at least 64 bits.
less than 64bit so.. long long should be good..
Try int64_t
. That should be long enough. But be sure to enter an integer literal:
int64_t n = 10000000000000000;
If you say 1E16
, that's a double
literal, and the conversion to integer may produce unexpected results.
Unsigned long long Int works up-to 10^18!
10^16
value is the problem?long long int
does not hold 10^16. It is somewhere in the logic of your program, which we can't see. So this question is answered. You should accept an answer and ask a new question about your code and what is wrong with it.