Introduced
Computers have little endian (small end) and big endian, two pictures stolen from Wikipedia to illustrate their differences:
For 32-bit integers, the big-endian machines are high in memory low address storage, low in high address storage.
Small-end machines on the contrary, memory low address storage low, high address storage high.
Big-end notation and intuitive comparison of people, from the low address to the high address to see the past, is the original number; The small terminal notation is more convenient for computer operation, and the increase of address and Chivan is consistent.
How to judge your computer is little endian or big endian it. Intel's machines are basically little endian, or they can run simple code judgments. method One:
Python-c "Import sys; Print (Sys.byteorder) "
Terminal to run the above code, my laptop output little is a small-end machine. Method Two:
Write a simple C program, the following is copied from the Nginx source:
#include <stdio.h>
int main () {
int i = 0x11223344;
char *p;
p = (char *) &i;
if (*p = = 0x44) {
printf ("Little endian\n");
}
else {
printf ("Big endian\n");
}
return 0;
}
And then you run it:
GCC test.c &&/a.out