Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

count bits c++

//Method 1
   int count = 0;
   while (n)
   {
        count++;
        n >>= 1;
    }
//Method 2
	int count = (int)log2(number)+1;
 
PREVIOUS NEXT
Tagged: #count #bits
ADD COMMENT
Topic
Name
4+4 =