2010年2月4日 星期四

Big endian, Little endian

big endian 與 little endian 指的是位元組在記憶體裡面的排列順序(詳細定義更複雜,這裡為方便起見以此為例)
  • big endian:較高的位元組在位址的較後位置,舉例來說
    long a = 0x12345678,這樣子的資料在記憶體裡面的排列順序為 0x12 0x34 0x56 0x78
    參考wiki的圖如下

    File:Big-Endian.svg

  • little endian:較高的位元組在位址的較前位置,繼續前面的例子
    long a = 0x12345678,這樣子的資料在記憶體裡面的排列順序為 0x78 0x56 0x34 0x12
    參考wiki的圖如下

    File:Little-Endian.svg

沒有留言:

張貼留言