In simple terms The so-called big- endian storage is the high-order content of the low address, then the small-endian storage is the low-order content exists at the high address. (picture to do with explanation)
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/7E/CE/wKiom1cI50nxpH7GAAAqkzvghIo428.png "title=" storage. png "alt=" Wkiom1ci50nxph7gaaaqkzvghio428.png "/>
In the computer, the data is in the form of the second complement is stored in the computer, the top of the big-endian storage and small pieces of storage, but each computer is not the same way of storage, then, how to determine whether a computer is interrupted storage or small pieces of storage it?!
Here's a single function to implement this function:
We know that 1 stored in the computer is 00000000 00000000 00000000 00000001 (complement), whose hexadecimal representation is FF FF FF, if the address is taken,
The computer is likely to display the following:———————— small End storage
Or:———————— big-endian storage
Therefore, when we know that the first bit of data storage after 1 can be judged that this computer is stored in the big-endian storage or small pieces of storage (of course, the numbers here can be given casually, but for the sake of convenience, choose 1)
int Sys_check () {int num = 1;char *p = (char *) # if (*p = = 1) return 1; Small end storage Elsereturn 0; Big-endian storage}int main () {int num = 1;int ret = Sys_check (); if (ret = = 1) {printf ("little\n");} else if (ret = = 0) {printf ("big\n");} System ("pause"); return 0;}
How to tell if your computer is big endian or small byte-order storage