I initialize an unsigned short int with a = 0xff (all bits are set). Then I assign b to → 7, which should give (0000 0001), and he does it. However, it is strange that when I assign c to <7, it is not equivalent (1000 0000). I tested this by outputting 0x80 (this is 1000 0000) and c, but they do not match.
Here is the code:
unsigned short int a = 0xff;
unsigned short int b = a>>7;
unsigned short int c = a<<7;
I am not sure what the problem is. Any help is appreciated. Thanks.
PS By "output" I mean output 0x80 and c in decimal and hexadecimal.
source
share