home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
vol_100
/
161_01
/
104.c
< prev
next >
Wrap
C/C++ Source or Header
|
1985-08-29
|
342b
|
26 lines
#include "timer1.h"
char c = 'c';
DO_IEXPR("Bit Count V2") bitcnt(c) OD
}
/* bitcnt - return the bit sum of a byte argument
* version 2
*/
#define BYTEMASK 0377
int bitcnt(c)
char c;
{
int b;
unsigned uc;
uc = c & BYTEMASK;
b = 0;
while (uc != 0)
{
if (uc & 01)
++b;
uc >>= 1;
}
return (b);
}