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

$0x0100 – 0001 = FF = (255)_{10}$

2 votes

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?

- $0\text{x}6665$
- $0\text{x} 0001$
- $0\text{x} 4243$
- $0\text{x} 0100$

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

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

10 votes

Best answer

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

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 :

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??

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 :

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

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

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.$

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{Memory[1]Memory[0]}$ [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)