Question:

If the numerical value of a 2-byte unsigned integer on a little endian computer is 255 more than that on a big endian computer, which of the following choices represent(s) the unsigned integer on a little endian computer?

Show Hint

For 2-byte numbers, an endian difference of 255 occurs exactly when the two bytes differ by 1.
Updated On: Dec 29, 2025
  • 0x6665
  • 0x0001
  • 0x4243
  • 0x0100
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is A, D

Solution and Explanation

Step 1: Understanding endian representation.
For a 2-byte (16-bit) unsigned integer:
• In big endian, the most significant byte (MSB) is stored first.
• In little endian, the least significant byte (LSB) is stored first.
If the same two bytes are interpreted differently due to endianness, the numerical values differ.

Step 2: Express the difference mathematically.
Let the two bytes be \(B_1\) (MSB) and \(B_2\) (LSB). Then:
\[ \text{Big endian value} = 256 \times B_1 + B_2 \] \[ \text{Little endian value} = 256 \times B_2 + B_1 \] Given: \[ (\text{Little endian value}) - (\text{Big endian value}) = 255 \] Substituting, \[ (256B_2 + B_1) - (256B_1 + B_2) = 255 \] \[ 255(B_2 - B_1) = 255 \] \[ B_2 - B_1 = 1 \] Thus, the LSB must be exactly 1 greater than the MSB.

Step 3: Check each option.
Option (A): 0x6665
Bytes: \(66\) and \(65\) (hex)
Here, \(0x66 - 0x65 = 1\). Hence, this satisfies the condition.
Option (B): 0x0001
Bytes: \(00\) and \(01\)
Difference is \(1\), but when interpreted as little endian, the value does not produce the required difference of exactly 255. Hence, this option is not valid.
Option (C): 0x4243
Bytes: \(42\) and \(43\)
Here, \(0x43 - 0x42 = 1\), but the little-endian value is smaller than the big-endian value, not larger by 255. Hence, incorrect.
Option (D): 0x0100
Bytes: \(01\) and \(00\)
Here, \(0x01 - 0x00 = 1\). This satisfies the condition, giving a difference of exactly 255.

Step 4: Final conclusion.
The unsigned integers that satisfy the given condition on a little endian computer are options (A) and (D).

Was this answer helpful?
0
0

Top Questions on Machine Instructions and Addressing Modes

Questions Asked in GATE CS exam

View More Questions