I'm trying to learn C and it seems to me that the 8-byte integer types uint64_t and long long just don't work.
If I run
int main() {
uint64_t a = 0xFFFFFFFF;
printf("a = %d, size = %d\n",a,sizeof(a));
return 0;
}
This prints "a = -1, size = 0"
as if it's treated as a 32-bit two's complement integer, instead of a 64-bit unsigned integer like it should be.
If I instead run with
uint64_t a = 0xFFFFFFFFFFFFFFFF;
The output is "a = -1, size = -1"
and if I run with leftmost F changed to 0
uint64_t a = 0x0FFFFFFFFFFFFFFF;
The output is "a = -1, size = 268435455"
Same results if I use long long, or long long int instead of uint64_t
Interestingly enough, running sizeof() on a double will return 8 like it should.
I'm using Windows 10, compiling with gcc, using the C99 standard library.