c++ - Bit shifting and assignment -
this question has answer here:
this sort of driving me crazy.
int = 0xffffffff; int b = 32; cout << (a << b) << "\n"; cout << (0xffffffff << 32) << "\n";
my output is
-1 0
why not getting
0 0
undefined behavior occurs when shift value number of bits not less size (e.g, 32 or more bits 32-bit integer). you've encountered example of undefined behavior.
Comments
Post a Comment