big endian VS little endian

big endian VS little endian   8086机器都是使用little endian, 而摩托罗拉的power pc使用big endian,对于一个数0x1122产用little endian方式时   低字节存储0x22,高字节存储0x11. 而使用big endian方式时,  低字节存储0x11, 高字节存储0x22 在这俩种字节方式间转换可以使用汇编指令 BSWAP

测试函数

 int IsBigEndian()

{       

  unsigned short test = 1;       

       return (*((unsigned char  *)&test) == 0);

 }

posted on 2012-01-27 20:33  李玉龙  阅读(152)  评论(0编辑  收藏  举报

导航