views:

18

answers:

1

If you have the integer 128 stored in a 2 byte / 16 bit integer mode memory, how is it layed out?

In binary, bigendian, I think it's this:

| 0000 0001 | 0000 0000 |

But in hex, that would be this:

| 0x01 | 0x00 |

even though 128 in hex is 0x80.

What am I not understanding?

+3  A: 

In big endian, the bits go from the highest to the lowest. In little endian, the bytes go from lowest to highest, but within each byte the bits are the same as big endian.

Little endian: | 10000000 | 00000000 | or 0x80 0x00

Big endian:    | 00000000 | 10000000 | or 0x00 0x80
Mark Ransom
.. thanks mark :)