Small end byte order and big endian byte order

Source: Internet
Author: User

The end pattern is divided into small-endian byte-order and big-end byte-order, which is the sequence of bytes in memory.

It is important to Note that for data, the high byte is the highest bit byte, which is the first bit on the left!

Small endian: Low bytes are stored in low memory addresses, and high bytes are stored in high memory addresses. such as a long type data 0x12345678

0x0029f458 0x78

0x0029f459 0x56

0x0029f45a 0x34

0x0029f45b 0x12

In the representation of the above data in memory, 0x0029f458 < 0x0029f459 < 0x0029f45a < 0x0029f45b,

It can be known that the memory address is from low to high order, and the data byte is from low to high, so the above byte order is the small endian.

Big endian byte order: High byte is stored in low memory address, low byte is stored in memory high address.

0x0029f458 0x12

0x0029f459 0x34

0x0029f45a 0x56

0x0029f45b 0x79

In the representation of the above data in memory, 0x0029f458 < 0x0029f459 < 0x0029f45a < 0x0029f45b,

It can be known that the memory address is from low to high order, and the data bytes are from high to low, so the above byte order is the big endian byte order.

network byte order: is the big endian byte order. Specifies that the network byte order is used for communication between different systems.

The experiment in VC is as follows:

int temp = 0x12345678;

In debugging, the variable in memory byte data is 78 56 34 12, in memory the storage address is: 0x0029f458,0x0029f459,

0X0029F45A,0X0029F45B, just meet the low in the lower address, indicating that the VC follows the small-endian byte sequence.

From: http://www.cnblogs.com/xiehy/archive/2010/11/25/1887779.html

Small end byte order and big endian byte order

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.