I don't understand the following behaviour of left bitwise shifting in C:
int x=0;
int y = 2 << (x-1);
// y is now 0
With the same compiler this expression evaluates as expected:
int y = 2 << (0-1);
// y is now 1
I don't understand the following behaviour of left bitwise shifting in C:
int x=0;
int y = 2 << (x-1);
// y is now 0
With the same compiler this expression evaluates as expected:
int y = 2 << (0-1);
// y is now 1