码迷,mamicode.com
首页 > 其他好文 > 详细

Check Big/Little Endian

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

标签:style   blog   ar   color   sp   div   log   bs   ad   

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

标签:style   blog   ar   color   sp   div   log   bs   ad   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!