# GATE CSE 2021 Set 2 | Question: 44

2 votes
2.1k views

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?

1. $0\text{x}6665$
2. $0\text{x} 0001$
3. $0\text{x} 4243$
4. $0\text{x} 0100$

recategorized ago
3
Option A and D

$0x6665 – 0x6566 = FF = (255)_{10}$

$0x0100 – 0001 = FF = (255)_{10}$
3
why are you assuming that given thing is as per little endian, question just talks about an unsigned representation..

if i interpret in this way, that the given is unsigned representation over a little endian machine, then i can even say for 0x66 65, the little endian storage would be like this way..

<in sequential locations we start by storing lsb first ...policy of little endian>

Address #1  0x 65

Address #2  0x 66

so this evaluates to 0x6566 on a little endian macinge, and 0x 66 65 over  a big endian machine, now little end- big end= 6566-6665 < 0 and not equal to 255 hence 0x6665 is wrong answer...similarly doing for rest gives, opt B,C as the only correct answers.

if you find anything wrong in this interpretation then tell me...bcoz i feel this way also one can interpret...and if there are multiple interpretation then question is ambiguous..

@Arjun Sir, @zxy123
0
No you’re right, but we have to wait for the answer key to be sure though.
3
A and D is correct.
0
How many marks was alloted for this question?
0
@ACCURACY by default it is little endian

## 4 Answers

10 votes

Best answer

This questions is poorly framed and has interpretation ambiguity. Refer the discussion on this question in below link :

https://cs.stackexchange.com/questions/135713/representation-of-unsigned-integer-on-a-little-endian-big-endian-computer

All kind of “interpretations” are available in that discussion.

The following is my interpretation from the question :

He is asking “which of the following choices represent(s) the unsigned integer on a little endian computer?

Take Option “0x6665” :

He is saying that 0x6665 is the representation of integer on a little endian computer, so, it means that the original number must have been 0x6566.

So, for the original number 0x6566 :

On little endian(LE) : 0x6665

On Big endian(BE) : 0x6566

Clearly, LE = 255 + BE

Similarly, for 0x0100.

Take 0x0100 :

He is saying that 0x0100 is the representation of integer on a little endian computer, so, it means that the original number must have been 0x0001.

So, for the number 0x0001 :

On little endian(LE) : 0x0100

On Big endian(BE) : 0x0001

Clearly, LE = 255 + BE

Similarly for 0x4243 and 0x0001, They do not satisfy “LE = 255 + BE”, So, answer is option A,D.

Refer Slide 26 in the below article :

Nice Reference : https://www.cs.utexas.edu/~byoung/cs429/slides2-bits-bytes.pdf  NOTE that different people are having different interpretation of this question. I have asked this question on cs.stackexchange, and you can read the discussion in below link :

https://cs.stackexchange.com/questions/135713/representation-of-unsigned-integer-on-a-little-endian-big-endian-computer

selected by
4
Perfect Explanation
0
sir i have one doubt (maybe silly).

Whatever be the representation style, will the computer not know what the number really is. So there will be no difference actually. But obviously seeing the options we can interpret what they really meant to ask.

Am i right??
0
Why are we assuming “ab” is a byte stored at lower address while “cd” is stored at higher address in 0xabcd? Isn’t it possible to have “ab” at higher address and “cd” at lower address?
2

This questions is poorly framed and has interpretation ambiguity. Refer the discussion on this question in below link :

https://cs.stackexchange.com/questions/135713/representation-of-unsigned-integer-on-a-little-endian-big-endian-computer

All kind of “interpretations” are available in that discussion.

2
Sir açcording to official answer key A,D are correct.. i marked B,C :(
3
It will be challenged. We will have to see final key for this. I think it is unlikely they will change it, But let’s see.
0
Did they change?

If not then what is the solution,

If yes, then ok.
0
Final answer of GATE was option A,D only. They did not change it.
7 votes
Ans: B and C.
0x0001 (binary: 0000 0000    0000 0001 ),as the value is stored in little endian would amount to 2^8*1 which is 256, however the same sequence of bits stored in big endian would amount to 2^0*1 =1 , so the liitle endian rep-BE rep=256-1=255
0x4243, same calculations as above(trick: just swap the 8 bits and look at the data bit’s that are not matching ) in this case too the difference between the little endian and big endian representation happens to be 256-1=255 hence both B and C are correct, the value given by option A and D is -255 as for those representations the little endian has a lower value than big endian system,
PS: In a big endian system the leftmost byte (sequence of 8 bits) are the most significant bytes [this is similar to how we generally solve binary numbers], however in a little endian system the sequence of bytes to the extreme left are least signigicant , it can be termed as mirror image of bytes as present in a big endian system
5 votes

$0\text{x}0001-$ On big endian computer (like humans read) this will read as $1$ and on little endian computer (lower byte comes at left most) this will read as $0\text{x}0100=256$ giving a difference of $255.$

Similarly, $0\text{x}4243$ also gives a difference of $255.$

Since, there is confusion regarding the meaning of the question, lets dissect the 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?

In the above question, the bold portion refers to the same thing. We have a $2-$ byte integer (say $X$ and this is represented on a little endian computer and this is now given in the options. So, lets consider option B for example. It is $0\text{x}0001$ which is the little endian representation. Its numerical is $00 + 0\text{x} 01 \times 256 = 256.$ That is, value of $X = 256$ on a little endian machine. Same byte sequence if read on a big endian machine will give $00 \times 256 + 01 = 1.$  That’s a difference of $256-1 = 255.$

edited by
1 vote

The way the question is framed, I do not agree with the concept at all.

A number is after all a number, be it big endian or little endian.

The main concept of Big endian or little endian is as follows:

Big Endian: In computer system which is big endian, the lower order byte of the data in the memory maps to the higher (big) order byte of the registers in CPU. (see figure below) Little Endian: In computer system which is little endian, the lower order byte of the data in the memory maps to the lower (little) order byte of the registers in CPU. (see figure below) As such, the whatever be the system type (Big or little endian) the number should actually be the same in the registers in the CPU, as the ALU knows one and only one representation of a number which is binary equivalent of a number.

The difference arises in the way the number is STORED IN THE MAIN MEMORY.

This makes the things a bit ambiguous.

Assuming they are taking about the representation of the number in main memory.

i.e. $\text{MemoryMemory}$ [A complete word] (see figure below) This ambiguity can be resolved by the way the question is asked.

From the above concept we can see that: what ever be byte sequence we assume for LITTLE ENDIAN, that byte sequence shall be reversed for BIG ENDIAN.

Option A:  $$0x6665–0x6566=FF=(255)_{10}$$

Option D:  $$0x0100–0x0001=FF=(255)_{10}$$

In other cases, (option B or C, assuming the given option and reversing the byte sequence gives a number greater than the option, as per the question the little endian value is greater)

edited by
Answer:

## Related questions

2 votes
3 answers
1
610 views
The format of the single-precision floating point representation of a real number as per the $\text{IEEE 754}$ ... $=00000000$ and mantissa $=0000000000000000000000001$ exponent $=00000001$ and mantissa $=0000000000000000000000000$ exponent $=00000001$ and mantissa $=0000000000000000000000001$
3 votes
2 answers
2
459 views
If $x$ and $y$ are two decimal digits and $(0.1101)_2 = (0.8xy5)_{10}$, the decimal value of $x+y$ is ___________
2 votes
2 answers
3
557 views
Consider the following sets, where $n \geq 2$: $S_1$: Set of all $n \times n$ matrices with entries from the set $\{ a, b, c\}$ $S_2$: Set of all functions from the set $\{0,1,2, \dots, n^2-1\}$ to the set $\{0, 1, 2\}$ Which of the following ... to $S_2$ There exists a surjection from $S_1$ to $S_2$ There exists a bijection from $S_1$ to $S_2$ There does not exist an injection from $S_1$ to $S_2$
1 vote
3 answers
4
590 views
Let $L_1$ be a regular language and $L_2$ be a context-free language. Which of the following languages is/are context-free? $L_1 \cap \overline{L_2} \\$ $\overline{\overline{L_1} \cup \overline{L_2}} \\$ $L_1 \cup (L_2 \cup \overline{L_2}) \\$ $(L_1 \cap L_2) \cup (\overline{L_1} \cap L_2)$