hamming weight


See On Github

Data

Contributor

Generic placeholder thumbnail

by grasGendarme

in c

Tags

Source Code

#include <stdint.h>

int32_t NumberOfSetBits(int32_t i)
{
    i = i - ((i >> 1) & 0x55555555);
    i = (i & 0x33333333) + ((i >> 2) & 0x33333333);
    return (((i + (i >> 4)) & 0x0F0F0F0F) * 0x01010101) >> 24;
}