Jan 09 - Number of 1 Bits; Bit Operation;
生活随笔
收集整理的這篇文章主要介紹了
Jan 09 - Number of 1 Bits; Bit Operation;
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
和 reverse Bits同一類(lèi)型
?
代碼:
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;
}
}
轉(zhuǎn)載于:https://www.cnblogs.com/5683yue/p/5117733.html
總結(jié)
以上是生活随笔為你收集整理的Jan 09 - Number of 1 Bits; Bit Operation;的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: win7 wifi
- 下一篇: 安装完最小化 RHEL/CentOS 7