It’s my understanding that uint64_t defined by C99 (stdint.h) is defined to be 8 bytes (= 64 bits) of length, thus allowing for a maximum value of 2^64 – 1. However, when I try the following code snippet, the uint64_t overflows, even though it’s nowhere near 2^64 – 1:
uint64_t Power10(int exponent)
{
int i = 1;
uint64_t ret = 10;
while(i < exponent)
{
ret *= 10;
++i;
}
return ret;
}
Help would be very much appreciated.
You need to print with
"%" PRIu64conversion. Don’t forget to add the right include!