Using bitwise operators left or right shift, moves every bit left or right. int x{5};
decimal|binary
5 =00000000 00000000 00000000 00000101 (because int is 4 bytes,32bits)
x=(x<<1);
The bits that move out are discarded and the bits that come in are 0.
decimal|binary
10 =00000000 00000000 00000000 00001010
If these are memory locations and our memory contains junk, why the bits that are inserted are always zero. Is there something that is setting them to zero?