Big endian machine: It thinks the first byte it reads is the biggest.
Little endian machine: It thinks the first byte it reads is the littlest.
舉個例子,從內(nèi)存地址0x0000開始有以下數(shù)據(jù)
?0x0000?????0x12
?0x0001?????0x34
?0x0002?????0xab
?0x0003?????0xcd
如果我們?nèi)プx取一個地址為0x0000的四個字節(jié)變量,若字節(jié)序為big-endian,則讀出
結果為0x1234abcd;若字節(jié)序位little-endian,則讀出結果為0xcdab3412.
如果我們將0x1234abcd寫入到以0x0000開始的內(nèi)存中,則結果為
????????????????big-endian?????little-endian
0x0000?????0x12??????????????0xcd
0x0001?????0x23??????????????0xab
0x0002?????0xab??????????????0x34
0x0003?????0xcd??????????????0x12
x86系列CPU都是little-endian的字節(jié)序.