count bits c 2b 2b

Solutions on MaxInterview for count bits c 2b 2b by the best coders in the world

showing results for - "count bits c 2b 2b"
Yohan
25 Aug 2020
1//Method 1
2   int count = 0;
3   while (n)
4   {
5        count++;
6        n >>= 1;
7    }
8//Method 2
9	int count = (int)log2(number)+1;