Reputation: 29935
It seems to work correctly, but I thought that the most that could be stored in memory was a 32 bit integer?
Now I'm confused as to what difference it makes.
Thanks!
Upvotes: 4
Views: 3056
Reputation: 39502
The difference isn't that you have 64-bit datatypes available to use. The difference is the size of the memory address space available, and the required size of pointers to memory. In a 32bit OS you have 2^32 bytes of addressable memory space, and you need 32-bit pointers to cover it all. In a 64-bit OS you have 2^64 bytes of memory space to address and so pointers must be 64-bit.
At a hardware level, intrinsic 64-bit datatypes may be more optimal on 64-bit hardware since there will be 64-bit registers and instructions to handle them. Otherwise the compiler/runtime library will be doing more work to support / emulate 64-bit operations on 32-bit hardware.
Upvotes: 6
Reputation: 1376
I think the other answers didn't quite explain this correctly.
uint64_t and int64_t are C-language data types, not hardware data types. The compiler does whatever it takes to make these types work as 64-bit unsigned or signed integers. If the hardware provides 64-bit registers and integer operations then well and good -- the compiler will use those directly. If the hardware has only 32-bit registers (or 16-bit or 8-bit), the compiler and runtime system use software emulation to get the job done.
Upvotes: 10