Give a very good method to count the number of ones in a "n" (e.g. 32) bit number.
public class Count {
public static void main(String args[])
{
int count=0;
int num=1101011011;
for(int i=0;i<6;i++)//统计的位数
{
if(num%Math.pow(10,i+1)==Math.pow(10,i))
count++;
num=(int) (num-num%Math.pow(10,i+1));
}
System.out.print(count);
}
}