Computer Arithmetic
What is the result of arithmetic right-shifting the 8-bit signed integer −8 (1111 1000) by one bit?
- A124 (0111 1100)
- B−16 (1111 0000)
- C−4 (1111 1100)
Show answer and explanation
Answer: C. −4 (1111 1100)
An arithmetic right shift copies the sign bit into the vacated top bit, so 1111 1000 becomes 1111 1100, which is −4 in two's complement. Even for negative numbers, shifting right by one divides by 2. A logical right shift, which inserts 0, gives 0111 1100 = 124, changing the sign. −16 is the result of shifting left by one. Note also that in C, which kind of shift applies to signed integers was historically left to the implementation.
- A. 124 is the result of a logical right shift inserting 0.
- B. −16 is the result of shifting left by one.
- C. Correct. Copying the sign bit gives 1111 1100 = −4.