hlabishi kobo wrote:
int weighted_bit_packet_count(TYPE_OF_WORD *seq_bits) { int i,check, count = 0; TYPE_OF_WORD word;
for (i = 0; i < NUM_WORDS; i++) { word = seq_bits[i]; int j = WORD_BIT_SIZE, k = 1;
while (j > 0 && k <= 32){
it is wrong to assume that unsigned long is 32 bit long.
check = (word & (1 << j)) >> j; if (check == 1) count += k; j--; k++;
I would doubt that it is correct to give every set bit the same weight when they have the the distance of sizeof(unsigned long)*8. And I cannot find a good reason why an "old" unsigned long should get the same weights as the "newest" unsigned long - at least not when the actual weights should be reduced for "older" bits in a single unsigned long and the overall weights should be monotonic decreasing with the age. And using WORD_BIT_SIZE for j is like assuming that we only have a single unsigned long in seq_bits... which is not true for many architectures.
And the code is overly complicated without any good reason.
Kind regards, Sven