Hamming Weight - Language Support

Language Support

Some C compilers provide intrinsics that provide bit counting facilities. For example, GCC (since version 3.4 in April 2004) includes a builtin function __builtin_popcount that will use a processor instruction if available or an efficient library implementation otherwise. LLVM-GCC has included this function since version 1.5 in June, 2005.

In C++ STL, the bit-array data structure bitset has a count method that counts the number of bits that are set.

In Java, the growable bit-array data structure BitSet has a BitSet.cardinality method that counts the number of bits that are set. In addition, there are Integer.bitCount(int) and Long.bitCount(long) functions to count bits in primitive 32-bit and 64-bit integers, respectively. Also, the BigInteger arbitrary-precision integer class also has a BigInteger.bitCount method that counts bits.

In Common Lisp, the function logcount, given a non-negative integer, returns the number of 1 bits. (For negative integers it returns the number of 0 bits in 2's complement notation.) In either case the integer can be a BIGNUM.

Read more about this topic:  Hamming Weight

Famous quotes containing the words language and/or support:

    Talking about dreams is like talking about movies, since the cinema uses the language of dreams; years can pass in a second and you can hop from one place to another. It’s a language made of image. And in the real cinema, every object and every light means something, as in a dream.
    Frederico Fellini (1920–1993)

    War ... should only be declared by the authority of the people, whose toils and treasures are to support its burdens, instead of the government which is to reap its fruits.
    James Madison (1751–1836)