# bit_count_c

num_set_bits.i4.v = bit_count_c(byte_array.g.v, start_bit.i4.v,
num_bits.i4.v, lowest_bit_set.i4.r,
highest_bit_set.i4.r)
This routine counts the number of set bits in a byte string.
A little endian byte ordering is assumed.
byte_array byte or array of bytes to test
start_bit starting bit number (starts at 1)
num_bits number of bits to test
lowest_bit_set bit number of lowest set bit found (starts at 1)
(If this value is not needed, a value of NULL
can be passed.)
highest_bit_set bit number of highest set bit found (starts at 1)
(If this value is not needed, a value of NULL
can be passed.)
This function returns status values as follows:
CLIB_INVARG invalid starting bit number or number of bits
otherwise number of set bits
This function requires the following include files:
cnsparam_h, clib_h
Related functions:
masked_off_bit_count_c, tstbit(_c), setbit(_c), rstbit(_c),
bit_field_circular_shift_c, icshft
C/C++ usage:
int num_set_bits;
int byte_array = VALUE;
int start_bit = 1;
int num_bits = 32;
int lowest_bit_set;
int highest_bit_set;
num_set_bits = bit_count_c((void *) &byte_array,start_bit,num_bits,
&lowest_bit_set,&highest_bit_set);