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.
舉個(gè)例子,從內(nèi)存地址0x0000開(kāi)始有以下數(shù)據(jù)
?0x0000?????0x12
?0x0001?????0x34
?0x0002?????0xab
?0x0003?????0xcd
如果我們?nèi)プx取一個(gè)地址為0x0000的四個(gè)字節(jié)變量,若字節(jié)序?yàn)閎ig-endian,則讀出
結(jié)果為0x1234abcd;若字節(jié)序位little-endian,則讀出結(jié)果為0xcdab3412.
如果我們將0x1234abcd寫入到以0x0000開(kāi)始的內(nèi)存中,則結(jié)果為
????????????????big-endian?????little-endian
0x0000?????0x12??????????????0xcd
0x0001?????0x23??????????????0xab
0x0002?????0xab??????????????0x34
0x0003?????0xcd??????????????0x12
x86系列CPU都是little-endian的字節(jié)序.