本文发表在 rolia.net/zh 相约加拿大网上社区枫下论坛
and 11010100 is actually little endian. Notice that in little endian, not only is the byte order reversed, but also is the bit order . Usually for char type, you don't care wether it's a big endian or little endian, but in the case of bit field, such as the header structure for a DNS query, you need to consider the "endianess" of the machine and throw in the conditional compile flag, check out the /usr/include/arpa/nameser.h or ip.h(I forgot the path) for the definition of network packet structures, they all have conditional compile flags.
2) mostly for integral types, for float or double types, usually they have a coprocessor which has its' own way of storing floats and doubles. That's why in Real-time operation, usualy people avoid float arithematics because it will slow down the whole process significantly.
3) compilers play an important role in correct data generation for machines with different byte order, in case of ELF dynamic link file format, a compiler will make sure that the byte order and alignment of data agree with the architecture. Of course, different compilers for the same machine generate different binary codes, but the byte order of the data should stay the same.
更多精彩文章及讨论，请光临枫下论坛. 网址: rolia.net/zh