技术的乐趣在于分享,欢迎多多交流,多多沟通。
全部博文(877)
发布时间:2014-09-05 12:57:25
//test for unsigned int and int#include <stdio.h>int main(void){ unsigned int foo;unsigned int i; int val = -4; foo = 3; //foo -= 7; i = foo + val; printf("%x\n",i); return 0;}.........【阅读全文】
发布时间: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类型,代码不够简洁,执行效率较低,.........【阅读全文】