The programmer knows that shifting left is the same as multiplying by a power of two. In other words:
x << 1 is the same as x * 2 (2 = 21)
x << 2 is the same as x * 4 (4 = 22)
x << 3 is the same as x * 8 (8 = 23)
The programmer uses this trick to quickly perform a simple calculation. But something goes wrong:
1 /************ *********** ************ **********
2 * Simple syntax testing. *
3 ************************************************/
4 #include <iostream>
5
6 int main(void)
7 {
8 int x,y; // Two numbers
9
10 x = 1;
11
12 y = x<<2 + 1; // x<<2 = 4 so y = 4+1 = 5
13 std::cout << "Y=" << y << std::endl;
14 return (0);
15 }