This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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; |