Difficulty: Medium
Correct Answer: 00 00 AC 40
Explanation:
Introduction / Context:
In C programming, the in-memory representation of floating-point numbers follows the IEEE-754 standard (for typical desktop compilers), and the byte order depends on the machine's endianness. Intel architectures are little-endian, meaning the least significant byte is stored at the lowest memory address. This question tests your understanding of IEEE-754 single-precision encoding and how pointer-based byte inspection reveals the byte order on Intel systems.
Given Data / Assumptions:
Concept / Approach:
IEEE-754 single precision encodes 5.375 as sign = 0, exponent = 129, fraction chosen so that 1.01011 * 2^2 = 5.375. In hex, this bit pattern is 0x40AC0000. On a big-endian system, bytes would appear in memory as 40 AC 00 00. On a little-endian system (Intel), the order in memory is reversed at the byte level, so the sequence read through a char* from lowest address becomes 00 00 AC 40.
Step-by-Step Solution:
Verification / Alternative check:
Cross-check with a float-to-hex table or by constructing the float: sign 0, exponent 129 (binary 1000 0001), fraction 010 1100 0000 0000 0000 000. Group into nibbles to confirm 0x40AC0000. Reversing byte order for little-endian confirms the printed order 00 00 AC 40.
Why Other Options Are Wrong:
40 AC 00 00: This is the big-endian order, not what p[0]..p[3] prints on Intel.
04 CA 00 00: Digits are permuted; exponent and fraction bits no longer match 5.375.
00 00 CA 04: Byte values and order do not correspond to 0x40AC0000 reversed.
Common Pitfalls:
Final Answer:
00 00 AC 40
Discussion & Comments