CSC373/406: C: Shift Operations [40/42] |
Left shift:
x == 01100010 x<<1 == 11000100 x<<2 == 10001000 x<<3 == 00010000 x<<4 == 00100000 x<<5 == 01000000 x<<6 == 10000000 x<<7 == 00000000 x<<8 == 00000000
Right shift:
(logical) (arithmetic) x == 01100010 01100010 x>>1 == 00110001 00110001 x>>2 == 00011000 00011000 x>>3 == 00001100 00001100 x>>4 == 00000110 00000110 x>>5 == 00000011 00000011 x>>6 == 00000001 00000001 x>>7 == 00000000 00000000 x>>8 == 00000000 00000000 (logical) (arithmetic) x == 11100010 11100010 x>>1 == 01110001 11110001 x>>2 == 00111000 11111000 x>>3 == 00011100 11111100 x>>4 == 00001110 11111110 x>>5 == 00000111 11111111 x>>6 == 00000011 11111111 x>>7 == 00000001 11111111 x>>8 == 00000000 11111111