CGEM BOSS
6.6.5.h
BESIII Offline Software System
Loading...
Searching...
No Matches
countBits.h
Go to the documentation of this file.
1
// Count the number of bits set in a word; return that number.
2
// Use a small lookup table. Size of lookup table is tradeoff between
3
// # of iterations needed and cache space used.
4
5
inline
int
countbits
(
unsigned
word) {
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
}
countbits
int countbits(unsigned word)
Definition
countBits.h:5
6.6.5.h
Reconstruction
MdcPatRec
MdcTrkRecon
MdcTrkRecon-00-03-49
MdcTrkRecon
countBits.h
Generated by
1.12.0