技术的乐趣在于分享,欢迎多多交流,多多沟通。
全部博文(877)
发布时间:2014-08-29 09:29:32
位反转Demo工程//Test for #define XXX()#include unsigned char fun4(unsigned char);int main(void){ unsigned char foo, chr = 0x53; //5a foo = fun4(chr); printf("%x\n",foo); return 0;}unsigned char fun4(unsigned char c){ c = ( (c & 0xaa) >> 1 ) | ( (c & 0x55) ......【阅读全文】
发布时间:2014-08-28 20:18:53
Write a C function to swap the bits of a unsigned char so that its bits become the mirror image of the char. MSBs become its LSBs, e.g. 01111000 binary should become 00011110 binary. 方法一:(最最容易想到的办法)unsigned char ReverseBitsInChar00(unsigned char&nb.........【阅读全文】
发布时间:2014-08-28 20:17:35
http://blog.csdn.net/jakee304/article/details/2152655题目要求如题所示:将一个字符按bit位逆序,例如一个字节是0x11,将其逆序后就变成0x88。下面是四种解法,其中最后一种效率最高,是从《Hacker's Delight》这本书中学来的。第一种:看似创新,其实最笨的做法。使用bit类型,代码不够简洁,执行效率较低,.........【阅读全文】
发布时间:2014-08-28 20:16:49
http://blog.jobbole.com/70993/green_t 提问:实现如下转换的最佳算法是什么?0010 0000 => 0000 0100具体的转换是从MSB->LSB 到 LSB->MSB,所有的位都必须反转,那意味着,这并不是字节顺序的交换。LSB(Least Significant Bit),意为最低有效位;MSB(Most Significant Bit),意为最高有效位。.........【阅读全文】