Skip to content

Instantly share code, notes, and snippets.

View gorset's full-sized avatar

Erik Gorset gorset

View GitHub Profile
@alexbowe
alexbowe / gist:907073
Created April 7, 2011 05:10
15bit popcount from Hacker's Delight, p. 72
//Special for 15-bit values on 64bit processors
//with fast multiplication
//From Hacker's Delight, p. 72
inline uint32_t popcount15(uint32_t x)
{
uint64_t y;
y = x * 0x0002000400080010;
y = y & 0x1111111111111111;
y = y * 0x1111111111111111;
y = y >> 60;