ITPEC FE Subject A April 2025 Question 1
For an 8-bit binary integer, which of the following is the operation that extracts the most significant 4-bits while making the other bits zero?
Explanation
AND with 11110000 — a mask keeps the bits where it has 1 and clears the bits where it has 0.
AND gives 1 only when both bits are 1, so ANDing a bit with 1 passes it through unchanged and ANDing it with 0 forces it to 0. The mask 11110000 has 1s over the upper four bits and 0s over the lower four.
Example: 10110101 AND 11110000 = 10110000. The upper half survives and the lower half becomes zero.
Answer (a)
Why not others:
- •(b) NAND with 11110000 — NAND inverts the AND result: the upper four bits come out inverted and the lower four become 1, not 0
- •(c) OR with 00001111 — OR with 1 forces a bit to 1, so the lower four bits become
1111instead of0000 - •(d) XOR with 00001111 — XOR with 1 flips a bit, so the lower four bits are inverted, not cleared
Key rule: AND with a mask clears the bits where the mask has 0, OR sets the bits where it has 1, and XOR inverts the bits where it has 1.
Basic Theory · AI-written, may contain errors
This question comes from an official ITPEC past paper. ITPEC Practice is an independent study tool and is not affiliated with ITPEC. See the official FE past-paper collection or Report an issue.