Big end, Small End

Source: Internet
Author: User

Big end, Small End

I always thought that I had a clear understanding of the differences between the big end and small end. I did not expect that I would still be confused in practical applications. Here I will record that the same mistake cannot be made again.

 

Uint32_t temp = 0x01020304;

Big end: the & temp address stores high bytes (uint8_t *) & temp) [0] = 0x01;

Small End: The & temp address stores low bytes, that is, (uint8_t *) & temp) [0] = 0x04;

 

Remember


What is the difference between the big-end storage method and the Small-end storage method?

The large-end mode stores low-end data on the high address. High positions are stored on the address.
The small-end mode stores the status on the low-end address. High positions are stored on high addresses.

For example, the storage method of 16-bit 0x1234 in Little-endian mode CPU memory (assuming that it starts from address 0x4000) is:
Memory Address 0x4000 0x4001
Storage content 0x34 0x12
In Big-endian mode, the CPU memory is stored as follows:
Memory Address 0x4000 0x4001
Storage content 0x12 0x34

Why can this function determine the big end and small end:

Yes. In 32-bit systems, int occupies 32 bits and char occupies 8 bits.
78 indicates small-end data, and 12 indicates large-end data.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.