An array of 2 two byte integers is stored in big endian machine in byte addresses as shown below. What will be its storage pattern in little endian machine? Address Data 0 × 104 78 0 × 103 56 0 × 102 34 0 × 101 12

An array of 2 two byte integers is stored in big endian machine in byte addresses as shown below. What will be its storage pattern in little endian machine? Address Data 0 × 104 78 0 × 103 56 0 × 102 34 0 × 101 12 Correct Answer <p>0 × 104    56</p> <p>0 × 103    78</p> <p>0 × 102    12</p> 0 × 101    34

Concept -

  • Little and big endian are two ways of storing multi-byte data-types like int, float, etc.
  • In little endian machines, last byte of binary representation of the multi-byte data-type is stored first.
  • On the other hand, in big endian machines, first byte of binary representation of the multi-byte data-type is stored first.

 

Explanation -

Given in the question is that each integer is of two bytes. For little endian-big endian, we will determine MSB and LSB of both the integers.

The big endian format,

104

103

102

101

78

56

34

12

MSB-1

LSB-1

MSB-2

LSB-2

 

MSB-1 refers to MSB of 1st integer.

For little endian, we simply have to reverse the exchange MSB with LSB and vice versa.

104

103

102

101

56

78

12

78

LSB-1

MSB-1

LSB-2

MSB-2

 

Hence, Option 3 is correct.

NOTE

if this was one integer with 4 bytes, then in little endian format, entire sequence would have been reversed.

Related Questions

Suppose we transfer a file written on a little endian machine to a big endian machine and there is no transformation from little endian to big endian, then what happens?
A teacher asked the class to subtract 5 from 75.70% of the class said: 25. Their work was shown as: \(\begin{array}{*{20}{c}} {\begin{array}{*{20}{c}} 7&5 \end{array}}\\ {\underline {\begin{array}{*{20}{c}}\ { - 5} \ \ \ &{} \end{array}} }\\ {\underline {\begin{array}{*{20}{c}} 2&5 \end{array}} } \end{array}\) Which of the following describes the most appropriate remedial action that the teacher should take to clarify this misconception?