问一个bit operation的题目# JobHunting - 待字闺中g*j2012-09-21 07:091 楼how to reverse the bit in an int as fast as possible?any trick?
C*U2012-09-21 07:093 楼32位的只要5个命令把我记得 就是那些数字比较难记住 我觉得【在 g***j 的大作中提到】: how to reverse the bit in an int as fast as possible?: any trick?
o*o2012-09-21 07:094 楼看我这个贴http://www.mitbbs.com/article/JobHunting/32182835_4.html另外补充一下:3.1 求一个二进制数中1的个数利用int countOne(int x) {int cnt = 0;while(x > 0) {x = x&(x-1);cnt++;}}3.2 给两个正整数A和B,问把A变为B需要改变多少bits?这个等价于A和B的二进制表示中有多少位是不同的C=A^B;countOne(C);