Which of the following operators can be used if a portion of a given bit…
2017
Which of the following operators can be used if a portion of a given bit pattern needs to be copied to a new word, while the remainder of the new word is filled with 0s?
- A.
Logical AND
- B.
Bitwise AND
- C.
Bitwise OR
- D.
Bitwise XOR
Attempted by 166 students.
Show answer & explanation
Correct answer: B
The correct option is B (Bitwise AND). To copy a portion of a bit pattern and clear the rest, we use a bitwise AND operation with a mask. Performing AND with 1 retains the original bit (X AND 1 = X), while AND with 0 forces the bits to 0 (X AND 0 = 0).