Answers for "python count number of bits set"

1

count number of bits set in a number

int count_one (int n)
        {
            while( n )
            {
            n = n&(n-1);
               count++;
            }
            return count;
    }
Posted by: Guest on August-13-2021
0

python count bits

counts = bytes(bin(x).count("1") for x in range(256))  # py2: use bytearray
Posted by: Guest on May-12-2021

Python Answers by Framework

Browse Popular Code Answers by Language