So I was just trying some bit manipulation in C++. Here is what I tried:
int a = 1<<2;
cout<<a;
This gives the output as 4.
int a = 1<<3;
cout<<a;
This gives the output as 8
But when I do:
int a = 1<<2 + 1<<3;
cout<<a;
It gives the output as 64. Why so?
I also tried:
int a = 1<<2;
int b = 1<<3;
cout<<a + b;
Which gives the output as 12 as expected.