Wrong hexadecimal representation in the memory view of eclipse

Viewed 93

In eclipse (2012-12) I inspected the memory of an int-array in unsigned integer and hexadecimal.

The int-array is defined as:

int Karray[] {1,2,3,4,5,6,255,258,18};

The memory view representing unsigned int is: The starting point in memory is highlighted in blue

On the other hand, if I switch to hexadecimal representation then I got the following result: Represenation flipped for 258 corresponding to 0x102 at address 0061FF10

The starting point in memory is also highlighted in blue. For all values despite of 258 it seems that the most-significant position is on the right and the least-significant position is on the left. But for the value of 258, it is represented in the memory by 201, thus it seems that the most-significant position is on the right and the least-significant position on the left.

Could someone can give me a hint to solve this contradiction?

1 Answers

The hexadecimal view is just showing the bytes in memory without trying to convert them to integers.

On your processor integer values are stored in memory in "Little Endian" format. This means that the least signifcant byte is stored at the lowest memory address.

So when loading the 02010000 bytes as an integer the value is constructed like this:

0x00 << 24 | 0x00 << 16 | 0x01 << 8 | 0x02

which is 258.

Related