24.190. 颠倒二进制位
public class Solution {
// you need treat n as an unsigned value
public static int reverseBits(int n) {
int result = 0; //存储答案
for (int i = 0; i < 32; i++) { //整数一共32位
result = (result << 1) | (n & 1);//将reslut左移一位,并且取出n的最低位放在result的最低位上
n >>>= 1; //n进行无符号右移
}
return result;
}
}