Jan 09 - Number of 1 Bits; Bit Operation;
生活随笔
收集整理的這篇文章主要介紹了
Jan 09 - Number of 1 Bits; Bit Operation;
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
和 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;
}
}
轉載于:https://www.cnblogs.com/5683yue/p/5117733.html
總結
以上是生活随笔為你收集整理的Jan 09 - Number of 1 Bits; Bit Operation;的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: win7 wifi
- 下一篇: 安装完最小化 RHEL/CentOS 7