~'q' << 6
is the same as (~'q') << 6
.
-
The operand of
~
operator is a "small integer"(char
here), thus its value is first promoted to a larger integral type(int
here).'q' = 01110001 promoted to 00000000 00000000 00000000 01110001
-
After the
~
operator evaluated,~'q' 11111111 11111111 11111111 10001110
-
Left shift,
~'q' << 6 11111111 11111111 11100011 10000000
-
The result is -7296.