首页 > 其他 > 详细

Jan 09 - Number of 1 Bits; Bit Operation;

时间:2016-01-10 07:05:34      阅读:129      评论:0      收藏:0      [点我收藏+]

和 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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!