1

When viewing memory addresses in Visual Studio, I noticed the arrangement changes depending on how the memory is viewed. Example:

int a = 3;

int* b = &a;

1 byte: 0x 03 00 00 00

2 byte: 0x 0003

4 byte: 0x 00000003

Now with a small number like this, it's not a big deal. But when viewing a larger number...

int a = 1012346589;

int* b = &a;

1 byte: 0x dd 2e 57 3c

2 byte: 0x 2edd 3c57

4 byte: 0x 3c572edd

That is all over the place, and it really trips me up because my intuitive assumption would be this, which is consistent with other tools I've used:

1 byte: 0x 00 00 00 03

2 byte: 0x 0003

4 byte: 0x 00000003

or

1 byte: 0x 3c 57 2e dd

2 byte: 0x 3c57 2edd

4 byte: 0x 3c572edd

I've used other memory debugging tools and this is the first where I've seen it arranged in this way. Is this just a quirk of visual studio, is it a setting?

At first, I thought maybe the 1 byte view was hiding the first 3 bytes because they were 0s, but after testing with larger numbers I found that wasn't the case, and the different views a sometimes produce completely different arrangements.

2
  • 1
    Your processor is little-endian. That's quite a fundamental property of its design, you'd better get used to it. en.wikipedia.org/wiki/Endianness Commented Jan 9, 2024 at 18:10
  • Hi, Hans Passant's comment was helpful. I'm posting his comment as an answer. You can mark it (click the check mark to the left of the answer) so that it can help more people Commented Jan 11, 2024 at 3:22

1 Answer 1

0

As Hans Passant said, your processor is little-endian. This is a very basic property of its design and you'd better get used to it.

Please refer to https://en.wikipedia.org/wiki/Endianness

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.