Difficulty: Medium
Correct Answer: 2
Explanation:
Introduction / Context:
Bitwise Boolean operations are ubiquitous for masking and extracting fields within registers. This problem combines a mask via AND and a subsequent field extraction from the result.
Given Data / Assumptions:
Concept / Approach:
Compute C with bitwise AND. Then read bits at positions 4 down to 2 (with bit 7 as MSB) to form a 3-bit number. Convert that 3-bit binary to decimal.
Step-by-Step Solution:
Compute AND: 1011 1010 AND 0011 0110 = 0011 0010 (0x32).Label bits of C (bit7..bit0): 0 0 1 1 0 0 1 0.Extract C[4..2] = bits 4,3,2 → 0 1 0 → binary 010 = decimal 2.
Verification / Alternative check:
Masking method: ((C >> 2) & 0b111) = 0b010 = 2 confirms the field value.
Why Other Options Are Wrong:
Values 1, 3, 4, 6 correspond to reading the wrong bit positions or reversing MSB/LSB order.
Common Pitfalls:
Confusing bit numbering or inadvertently using OR instead of AND; always define MSB and LSB conventions explicitly.
Final Answer:
2
Discussion & Comments