https://codeeval.dev/gist/28269399b1e86a5a3af470cc35ec8908

Why

The left bit wise shift will shift the bits of the left hand value (a) the number specified on the right (1), essentially padding the least significant bits with 0’s, so shifting the value of 5 (binary 0000 0101) to the left 4 times (e.g. 5 << 4) will yield the value of 80 (binary 0101 0000). You might note that shifting a value to the left 1 time is also the same as multiplying the value by 2, example:

int a = 7;
while (a < 200) {
    std::cout << "a = " << a << std::endl;
    a <<= 1;
}

a = 7;
while (a < 200) {
    std::cout << "a = " << a << std::endl;
    a *= 2;
}

But it should be noted that the left shift operation will shift all bits to the left, including the sign bit, example:

https://codeeval.dev/gist/5c7206c1cdb43adf3fe351ea74406ac7

While some compilers will yield results that seem expected, it should be noted that if you left shift a signed number so that the sign bit is affected, the result is undefined. It is also undefined if the number of bits you wish to shift by is a negative number or is larger than the number of bits the type on the left can hold, example:

int a = 1;
int b = a << -1;  // undefined behavior
char c = a << 20; // undefined behavior

The bit wise left shift does not change the value of the original values unless specifically assigned to using the bit wise assignment compound operator <<=:

https://codeeval.dev/gist/1b8f6d411435f78755d3e2fa75af7d3a