Java Bit Count bitcount(int num)

Here you can find the source of bitcount(int num)

Description

bitcount

License

Apache License

Declaration

public static int bitcount(int num) 

Method Source Code

//package com.java2s;
/**/*from  w  ww.  ja va 2 s .  c om*/
 * HashMap?????????????????????????new??????????????????????????
 * ????????
 * code by guava-libraries.(Apache License 2.0)
 * https://code.google.com/p/guava-libraries/
 *
 * @return HashMap????????????????????????
 */

public class Main {

    public static int bitcount(int num) {
        int count = 0;
        while (num > 0) {
            count += num % 2;
            num /= 2;
        }
        return count;
    }
}

Related

  1. bitCount(byte b)
  2. bitCount(final Integer i)
  3. bitCount(int i)
  4. bitCount(int x)
  5. bitCount(String s)
  6. bitCountSlow(int x)
  7. bitLength(byte[] bytes)