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?

This question was previously asked in
GATE CS 2021 Official Paper: Shift 2
View all GATE CS Papers >
  1. 0x0001
  2. 0x6665
  3. 0x0100
  4. 0x4243

Answer (Detailed Solution Below)

Option :
Free
GATE CS Full Mock Test
5.4 K Users
65 Questions 100 Marks 180 Mins

Detailed Solution

Download Solution PDF

2,3 is the correct answer. 

concept:

If you split hex number into bytes,
In hexadecimal representation, each digit corresponds to 4 binary digits.(i.e 2 hex digits = 8 bits= 1 byte). 

If  little-endian representation used then byte arrangement is as follows:

byte_n

byte_n-1

…………..

byte_1

if Big endian representation is used then the byte arrangement is as follows:

byte_1

byte_2

…………..

byte_n

Within the byte no change in the bit sequence.

A) 0x0001 is incorrect.
Little-endian 0x0001  gives you 01 as the first byte and 00 as the second byte, So the corresponding big-endian representation is 0x0100.
Hex (0x0001) is equal to 1 in decimal 
Hex(0x0100) is equal to 256 in decimal. 
Their difference is -255.

B) 0x6665 is correct
Little-endian 0x6665  gives you 65 as the first byte and 66 as the second byte, So the corresponding big-endian representation is 0x6566.
Hex (0x6665) is equal to 26213 in decimal 
Hex(0x6566) is equal to 25958 in decimal. 
Their difference is 255.

C) 0x0100 is correct
Little-endian 0x0100  gives you 00 as the first byte and 01 as the second byte, So the corresponding big-endian representation is 0x0100
Hex(0x0100) is equal to 256 in decimal.,
Hex (0x0001) is equal to 1 in decimal 

Their difference is 255.

D)0x4243 is incorrect
Little-endian 0x4243  gives you 43 as first byte and 42 as the second byte, So the corresponding big-endian representation is 0x4342
Hex(0x4243) is equal to 16963  in decimal.
Hex (0x4342) is equal to  17218 in decimal. 
Their difference is -255.

So 2,3 is the answer 

Latest GATE CS Updates

Last updated on Jan 8, 2025

-> GATE CS 2025 Admit Card has been released on 7th January 2025.

-> The exam will be conducted on 1st February 2025 in 2 shifts.

-> Candidates applying for the GATE CE must satisfy the GATE Eligibility Criteria.

-> The candidates should have BTech (Computer Science). Candidates preparing for the exam can refer to the GATE CS Important Questions to improve their preparation.

-> Candidates must check their performance with the help of the GATE CS mock tests and GATE CS previous year papers for the GATE 2025 Exam.

Get Free Access Now
Hot Links: teen patti master gold download teen patti cash teen patti game