...
Number-Systems
November 12, 2024
Number-Systems
November 12, 2024
Number-Systems
November 12, 2024
Number-Systems
November 12, 2024

Number-Systems

Question 31
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?
A
0x4243
B
0x6665
C
0x0001
D
0x0100
Question 31 Explanation: 

It is given that the unsigned integer is 2-bytes long. It needs 4 hexadecimal digits.

We know the big-endian and little-endian computers differ in how the data is stored in memory.

 

In little endian machines, the last byte of binary representation of the multibyte data-type is stored first. On the other hand, in big endian machines, the first byte of binary representation of the multibyte data-type is stored first.

 

In the hexadecimal representation of the 2-byte number on the little endian machine, the first two hexadecimal digits are for one byte and the last two hexadecimal digits are for the second byte. On the big endian machine it is the other way round. 

 

It is given that the value in little endian representation is 255 more than the value in the big endian machine.

 

From the given options 

A). In little endian = 0x4243 in binary (0100 0010 0100 0011) which has decimal value = 16963

On big endian = 0x4342 in binary (0100 0011 0100 0010) which has decimal value = 17218 

Here the big endian value is higher than the little endian value. So this is not the correct option.

 

B). In little endian 0x6665 in binary (0110 0110 0110 0101) which has the decimal value = 26213

In big endian 0x6566 in binary (0110 0101 0110 0110) which has the decimal value = 25958

The difference = 26213 – 25958 = 255. So this is also the correct option. 

 

C). In little endian 0x0001 in binary (0000 0000 0000 0001) which has the decimal value = 1.

In big endian 0x0100 in binary (0000 0001 0000 0000) has decimal value = 256.

But here also the big endian value is higher than the little endian. So this is not the correct option.

 

D). On the little endian machine for hexadecimal number 0x0100 in binary (0000 0001 0000 0000) which has decimal value = 256. On a big endian machine it is 0x 0001 in binary  (0000 0000 0000 0001) which has decimal value = 1

 

The difference in value of little endian to big endian is 256-1 = 255.

 

Hence 2, 4 are the correct options.

Correct Answer: B
Question 31 Explanation: 

It is given that the unsigned integer is 2-bytes long. It needs 4 hexadecimal digits.

We know the big-endian and little-endian computers differ in how the data is stored in memory.

 

In little endian machines, the last byte of binary representation of the multibyte data-type is stored first. On the other hand, in big endian machines, the first byte of binary representation of the multibyte data-type is stored first.

 

In the hexadecimal representation of the 2-byte number on the little endian machine, the first two hexadecimal digits are for one byte and the last two hexadecimal digits are for the second byte. On the big endian machine it is the other way round. 

 

It is given that the value in little endian representation is 255 more than the value in the big endian machine.

 

From the given options 

A). In little endian = 0x4243 in binary (0100 0010 0100 0011) which has decimal value = 16963

On big endian = 0x4342 in binary (0100 0011 0100 0010) which has decimal value = 17218 

Here the big endian value is higher than the little endian value. So this is not the correct option.

 

B). In little endian 0x6665 in binary (0110 0110 0110 0101) which has the decimal value = 26213

In big endian 0x6566 in binary (0110 0101 0110 0110) which has the decimal value = 25958

The difference = 26213 – 25958 = 255. So this is also the correct option. 

 

C). In little endian 0x0001 in binary (0000 0000 0000 0001) which has the decimal value = 1.

In big endian 0x0100 in binary (0000 0001 0000 0000) has decimal value = 256.

But here also the big endian value is higher than the little endian. So this is not the correct option.

 

D). On the little endian machine for hexadecimal number 0x0100 in binary (0000 0001 0000 0000) which has decimal value = 256. On a big endian machine it is 0x 0001 in binary  (0000 0000 0000 0001) which has decimal value = 1

 

The difference in value of little endian to big endian is 256-1 = 255.

 

Hence 2, 4 are the correct options.

Leave a Reply

Your email address will not be published. Required fields are marked *