Small byte order and large byte order

Source: Internet
Author: User

Small byte order: (for example, x86 System) Low bytes of data are placed at a low address, for example, an integer of 0x12345678, in the memory
Distribution:
-----------
| 78 | xxxx_0000
-----------
| 56 | xxxx_0001
-----------
| 34 | xxxx_0002
-----------
| 12 | xxxx_0003
-----------

Little endian

Large byte order: (such as the PowerPC System) the low bytes of data are placed at the high address. For example, if an integer is 0x12345678
Distribution:
-----------
| 12 | xxxx_0000
-----------
| 34 | xxxx_0001
-----------
| 56 | xxxx_0002
-----------
| 78 | xxxx_0003
-----------

Big endian

For example, the following struct definition is available:

Typedef struct
{
Unsigned short rsvd: 4;/* rsvd0 .*/
Unsigned short tgid: 6;/* this is the group number .*/
Unsigned short index: 6;/* This is index for this COM use .*/
} My_struct;

1234 value = 0 X;
My_struct * P;
P = (my_struct *) & value;

(1) In a system with a small byte order, its distribution is as follows:

15 10 | 9 4 | 3 0
---------------------------------
| Index | tgid | rsvd |
---------------------------------
If the value is 0x1234, then:
0001 0010 0011 0100
Rsvd: 0x04
Tgid: 0x23
Index: 0x04

(2) In a large byte ordering system, its distribution is as follows:

15 12 | 11 6 | 5 0
--------------------------------
| Rsvd | tgid | index |
--------------------------------
If the value is 0x1234, then:
0001 0010 0011 0100
Rsvd: 0x01
Tgid: 0x08
Index: 0x34

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.