Cisco Systems Interview Question
Software Engineer / DevelopersCountry: United States
Interview Type: Phone Interview
Since its a negative (signed) number, it is an arithmetic shift. The MSB value remains and does not go away. Read more about arithmetic shift in wikipedia.
-16 in 2's compliment is like this:
16 in binary:
00000000 00000000 00000000 00010000
Flip all the bits now:
11111111 11111111 11111111 11101111
Now add "1" to it.
11111111 11111111 11111111 11110000
which is nothing but fffffff0.
Hope this helps.
Good question. This is an arithmetic shift and not a logical shift.
- anon.coder May 03, 2012-1<<4 = -16.
-16 in 2's compliment is stored as fffffff0.