|
|
1.1 root 1: # include <sccs.h>
2:
3: SCCSID(@(#)bitcnt.c 7.1 2/5/81)
4:
5:
6: /*
7: ** Count the number of 1's in the integer var. As long
8: ** as left shift is zero fill this routine is machine
9: ** independent.
10: */
11:
12: bitcnt(var)
13: register int var;
14: {
15: register int i, ret;
16:
17: for (ret = 0, i = 1; i; i <<= 1)
18: if (i & var)
19: ret++;
20:
21: return (ret);
22: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.