• + 0 comments

    This is quick hack for gcc __builtin_popcount function. There is NO __builtin_popcount in c++, it's a built in function of GCC.

    The function prototype is as follows:

    int  __builtin_popcount(unsigned int)
    

    though there are additional implementations of this function for long and long long types.

    It returns the numbers of bits in an integer (the number of ones in the binary representation of the integer).

    This function tries to use CPU specific instructions, which will always be orders of magnitude faster than any algorithm you manage to come up with.

    Since this is highly compiler specific implementation and here we do reference implementations rather then production ones I proposed to use the builtin replacement for the CassioNeri implementation (gcc specific).