摘要:
long count_bits(long n) { unsigned int c; // c accumulates the total bits set in v for (c = 0; n; c++) n &= n - 1; // clear the least significant bit set return c;}http://gurmeetsingh.wordpress.co... 阅读全文
摘要:
The best method for counting bits in a 32-bit integer v is the following: http://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel B[0] = 0x55555555 = 01010101 01010101 01010101 01010... 阅读全文