85.8k views
3 votes
Address ∣ Value

0XA02A ∣ 0X40
0XA02B ∣ 0X00
0XA02C ∣ 0X02
0XA02D ∣ 0XB0

a. (5 points) Assuming that these four bytes represent. an sign-marnitude 32-bit integer in a little-endian machine, its decimal numerical value is ___
b. (5 points) Assuming that these four bytes represent a 2 's complement 32 -bit integer in a big-endian machine, its decimal numerical value is ___

1 Answer

0 votes

Final answer:

For a little-endian sign-magnitude 32-bit integer, the memory values correspond to -688, and for a big-endian 2's complement 32-bit integer, the values correspond to 1073779696.

Step-by-step explanation:

To answer the student's question, we must interpret the values stored in memory differently depending on the endianness and integer representation. For a little-endian machine, the bytes are read from the least significant to the most significant, while in a big-endian machine, the bytes are read from the most significant to the least significant.

a. Little-Endian Sign-Magnitude: Sign-magnitude representation indicates the first bit is for the sign, and the rest are the magnitude. The bytes in little-endian order are 0XB0, 0X02, 0X00, 0X40. Since the highest bit in 0XB0 is set, this represents a negative number. The magnitude is then 0X00 0X02 0XB0 (ignoring the sign bit), which is hexadecimal for 688. Therefore, the number is -688.

b. Big-Endian 2's Complement: In 2's complement, the value is negative if the highest bit is set. Reading the bytes in big-endian gives us 0X40 0X00 0X02 0XB0. The highest bit is not set, indicating this is a positive number. We simply convert 0X400002B0 to decimal, yielding 1073779696.

User TRD
by
8.5k points
Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.