pop_count

Run Settings
LanguageC
Language Version
Run Command
#include <stdio.h> unsigned pop_count(unsigned a) { unsigned b = (a & 0x55555555) + ((a & 0xAAAAAAAA) >> 1); unsigned c = (b & 0x33333333) + ((b & 0xCCCCCCCC) >> 2); unsigned d = (c & 0x0F0F0F0F) + ((c & 0xF0F0F0F0) >> 4); unsigned e = (d & 0x00FF00FF) + ((d & 0xFF00FF00) >> 8); unsigned f = (e & 0x0000FFFF) + ((e & 0xFFFF0000) >> 16); return f; } int main(void) { printf("%u\n", pop_count(0xFFFFFFFF)); printf("%u\n", pop_count(0)); printf("%u\n", pop_count(0xFFF0FFFF)); return 0; }
Editor Settings
Theme
Key bindings
Full width
Lines