Search code examples
32bit-64bitunsigned-long-long-int

Will a 64-bit Unsigned Integer wrap around on 32-bit system?


Simple question, need an answer quickly please!

Take this situation on a 32-bit machine:

Unsigned long long n = 1;
n -= 2;

I know on a 64-bit machine, this would wrap around to the highest unsigned long long. But what would happen on a 32-bit machine, since the long long is stored as two separate words?

Thank you!


Solution

  • If the implementation is conforming, then the same: it will correctly wrap around. I assume this is C; The C standard requires this behavior independently from the implementation details.