c++ - Bit shifting and assignment -


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

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -