Difficulty: Easy
Correct Answer: Incorrect — ordinary shifts do not rotate; they discard shifted-out bits
Explanation:
Introduction / Context:
This concept distinguishes between shift and rotate operations. Many beginners mistakenly believe that shifting “wraps” bits around. In C/C++, the standard shift operators «<<» and »>>« are shifts, not rotates. Rotates require special intrinsics, inline assembly, or explicit code to simulate wrapping behavior.
Given Data / Assumptions:
Concept / Approach:
Left shift moves bits toward more significant positions. The vacated rightmost positions are filled with zeros. Bits that move past the most significant position are discarded. There is no implicit rotation. Right shift works similarly but toward less significant positions; for unsigned types, zeros enter on the left; for signed types, left-fill may be zeros or sign bits, depending on implementation.
Step-by-Step Solution:
Verification / Alternative check:
Try examples in a small C program; you will never see wrap with standard shift operators unless you explicitly code it with ORs and masks.
Why Other Options Are Wrong:
Common Pitfalls:
Confusing rotate with shift; assuming hardware CPU rotate instructions are automatically used by the compiler for «<<» or »>>« semantics (they are not).
Final Answer:
Incorrect — ordinary shifts do not rotate; they discard shifted-out bits.
Discussion & Comments