这是什么功能呢? [英] What does this function do?
本文介绍了这是什么功能呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我读它包含以下功能,这是
I am reading a program which contains the following function, which is
int f(int n) {
int c;
for (c=0;n!=0;++c)
n=n&(n-1);
return c;
}
我不明白这是什么功能打算做什么?
I don't quite understand what does this function intend to do?
推荐答案
据<一个href=\"http://stackoverflow.com/questions/109023/best-algorithm-to-count-the-number-of-set-bits-in-a-32-bit-integer/109036#109036\">counts 1在n个二进制重新presentation 数
这篇关于这是什么功能呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文