首页 > 其他 > 详细

Check Big/Little Endian

时间:2014-11-21 10:21:47      阅读:107      评论:0      收藏:0      [点我收藏+]

Little endian:Low memory address stores low byte value.(eg.  short int 0x2211   0xbfd05c0e->0x11 | 0xbfd05c0f->0x22)

Big endian:Low memory address stores high byte value. (eg.  short int 0x2211   0xbfd05c0e->0x22 | 0xbfd05c0f->0x11)

 

#include <endian.h>

bool IsLittleEndian1()

{

    return BYTE_ORDER == LITTLE_ENDIAN ? true : false;

}



bool IsLittleEndian2()

{

    short endian = 0x2211;



    return *((char*)(&endian)) == 0x11 ? true : false;

}

 

Check Big/Little Endian

原文:http://www.cnblogs.com/stanley198610281217/p/4112079.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!