Given what you started with (zeros in the two rightmost bits) you can't get that after shifting left two bits. You're going to end-up with 4 zeros in the 4 rightmost bits.
'a' is a 16-bit value. When you set it to 0b11001100 you get:
0b0000000011001100
shifted left two bits you get:
0b0000001100110000
There are lots of ways to get 0000000000001100:
You could do 'a >> 4' instead of 'a << 2'.
You could mask away all but the bottom 4 to 6 bits:
a & 0b0000000000001111
a & 0b0000000000011111
a & 0b0000000000111111
What made you think that shifting left two bits was what you wanted to do?
'a' is a 16-bit value. When you set it to 0b11001100 you get:
0b0000000011001100
shifted left two bits you get:
0b0000001100110000
Everything is right, this 16-bit value. But if I shift 8 bits, then as a result I receive additional zero, and values do not move.
The most interesting that in a week earlier everything worked))
I could solve a problem having replaced int with uint16_t.
ybpvin:
Everything is right, this 16-bit value. But if I shift 8 bits, then as a result I receive additional zero, and values do not move.
I don't understand what you mean by "if I shift 8 bits, then as a result I receive additional zero, and values do not move". Can you show a small sketch that demonstrates the problem?
johnwasser:
I don't understand what you mean by "if I shift 8 bits, then as a result I receive additional zero, and values do not move". Can you show a small sketch that demonstrates the problem?