和 reverse Bits同一类型
代码:
public class Solution {
// you need treat n as an unsigned value
public int reverseBits(int n) {
int result = 0;
for(int i = 32; i > 0; i--){
result = result << 1;
result = result + (n & 1);
n = n >>> 1;
}
return result;
}
}
Jan 09 - Number of 1 Bits; Bit Operation;
原文:http://www.cnblogs.com/5683yue/p/5117733.html