Prepare for the A Level Computer Science OCR Exam with comprehensive quizzes that cover essential topics, flashcards, and detailed explanations to help you excel. Ace your exam with confidence!

Practice this question and more.


Which type of shift operation retains the sign of a number?

  1. Logical shift

  2. Cyclic shift

  3. Arithmetic shift

  4. Direct shift

The correct answer is: Arithmetic shift

The correct choice is the arithmetic shift operation. In computing, an arithmetic shift involves shifting the bits of a binary number to the left or right while maintaining the sign bit, which is the most significant bit (MSB) that indicates the number's sign in two's complement representation. For a right arithmetic shift, the number is divided by two for each shift, and the sign bit is preserved by replicating it into the new positions created on the left. This means that if the number is negative, the sign remains negative after the operation. Conversely, the left arithmetic shift operates the same way as a logical shift, effectively multiplying the number by two. In contrast, a logical shift simply moves bits without any attention to the sign. A cyclic shift rotates the bits rather than moving them into new positions, while a direct shift isn’t a standard term with a clear definitive operation in shifting practices. Overall, the arithmetic shift is specifically designed to handle signed numbers correctly, making it the right choice in this context.