BOSS 7.0.7
BESIII Offline Software System
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
countBits.h File Reference

Go to the source code of this file.

Functions

int countbits (unsigned word)
 

Function Documentation

◆ countbits()

int countbits ( unsigned  word)
inline

Definition at line 5 of file countBits.h.

5 {
6 const int nbit[16] = { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4 };
7 int nset=0;
8 for (unsigned i=0;i<2*sizeof(unsigned);i++) { // assume char = 8 bits, i.e. two
9 nset+=nbit[word&0xf]; // iterations per 'char' size object
10 word>>=4;
11 }
12 return nset;
13}
short int word(short i, const _T &v)
Definition: bitmanip.h:27

Referenced by MdcSegPatterns::MdcSegPatterns().