Add bit counter to utils

This commit is contained in:
Pavel Krajcevski 2014-03-10 14:58:36 -04:00
parent 5a68febdda
commit 56c199fc5d

View file

@ -101,6 +101,14 @@ namespace ASTCC {
return -1; return -1;
}; };
// Count the number of bits set in a number.
Popcnt(uint32 n) {
uint32 c;
for(c = 0; n; c++) {
n &= n-1;
}
return c;
}
} // namespace ASTCC } // namespace ASTCC
#endif // ASTCENCODER_SRC_UTILS_H_ #endif // ASTCENCODER_SRC_UTILS_H_