How to distinguish between small and big end

Source: Internet
Author: User
C program development, sometimes involves the concept of big and small end.
Let's take a look at the concept of small ends first. For example, there is a contiguous area of memory in memory, the address from 0x0 to 0x3; now there is an integer, with a 16 binary representation is 0x12345678, every two digits is a byte (16 concept everyone can be under Baidu), 0x12 is the highest byte, 0x78 is the lowest byte. Now save this integer in memory, as shown in the following illustration:


Memory address

0x0

0x1

0x2

0x3

Storage content

0x12

0x34

0x56

0x78


The highest byte of the integer 0x12 is stored in the lowest address of the memory 0x0, the lowest byte of the integer 0x78 is stored in the highest address of memory 0x3, which is the big-endian.

If stored as follows:


Memory address

0x0

0x1

0x2

0x3

Storage content

0x78

0x56

0x34

0x12

The highest byte of an integer 0x12 stored in the highest address of the memory 0x3, the lowest byte of the integer 0x78 stored in the lowest address of memory 0x0, which is the small end.

can also use the C program to determine whether the current system is big or small end, the specific C program please see the next 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.