compute number of 1 bits in a binary representation of a number The goal is to write a program that returns number of 1 bits in a given number.

Examples

5      -&gt;  2
1254   -&gt;  6
56465  -&gt;  8


Winner

The winning submission is the code which runs in the minimum time. You can assume that normal int value in your language can handle any number (no matter how large) and computes all the valid operators defined for integer in O(1).

If two pieces of code run in the same time the winner is the one implemented in fewer bytes.

Please provide some explanation how your code is computing the result.
C/C++
int popcnt(int n)
{
    return __builtin_popcount(n);
}

For some CPUs __builtin_popcount compiles to a single instruction (e.g. POPCNT on x86).
Note: requires gcc or gcc-compatible compiler (e.g. ICC).