Flashcard
Calculate the result of the Bit Shift operation (Result = Value << N or Value >> N):
How to calculate: Shift all bits in the binary representation of Value either left (<<
) or right (>>
) by N positions. For left shifts, fill the vacated positions on the right with 0s. For right shifts, bits shifted off the end are discarded; the vacated positions on the left are typically filled with 0s (logical shift).
Example (Left Shift): 0x05 << 3
(Binary 00000101 << 3
) results in 00101000
, which is 0x28
.
Example (Right Shift): 0xA8 >> 2
(Binary 10101000 >> 2
) results in 00101010
, which is 0x2A
.
?