随笔 - 50  文章 - 8  trackbacks - 0
<2010年3月>
28123456
78910111213
14151617181920
21222324252627
28293031123
45678910

常用链接

留言簿

随笔档案

Blogs

搜索

  •  

最新评论

阅读排行榜

评论排行榜

This tip outlines two simple methods that help you to convert a number from the "little-endian" format to the "big-endian" format.


// 2-byte number
int SHORT_little_endian_TO_big_endian(int i)
{
return ((i>>8)&0xff)+((i << 8)&0xff00);
}

// 4-byte number
int INT_little_endian_TO_big_endian(int i)
{
return((i&0xff)<<24)+((i&0xff00)<<8)+((i&0xff0000)>>8)+((i>>24)&0xff);
}


文章来源:http://sohu2000000.spaces.live.com/Blog/cns!87FC8F72BEB4FD03!419.entry
posted on 2010-03-22 10:37 sohu2000000 阅读(321) 评论(0)  编辑 收藏 引用

只有注册用户登录后才能发表评论。
网站导航:   博客园   博客园最新博文   博问   管理