Difficulty: Easy
Correct Answer: ffdf
Explanation:
Introduction / Context:
This problem tests bitwise operations on fixed-width integers and hexadecimal formatting with printf. Assuming unsigned int is 16 bits, 32 decimal equals 0x0020 in hex.
Given Data / Assumptions:
Concept / Approach:
On 16 bits, ~0x0020 = 0xffdf because all bits invert: the bit 5 (value 0x0020) goes from 1 to 0 and the rest from 0 to 1, producing 1111 1111 1101 1111.
Step-by-Step Solution:
32 = 0x0020 (binary 0000 0000 0010 0000).~0x0020 = 1111 1111 1101 1111 = 0xffdf.printf prints ffdf.
Verification / Alternative check:
Compute with the identity ~x = (2^n - 1) - x for n-bit unsigned: (2^16 - 1) - 0x0020 = 0xffff - 0x0020 = 0xffdf.
Why Other Options Are Wrong:
ffff: would be ~0, not ~32.0000 / ddfd: do not match the exact bitwise inversion.
Common Pitfalls:
Forgetting the assumed width; mixing signed and unsigned notions; misreading printf format.
Final Answer:
ffdf
Discussion & Comments