What's the quickest way to compute log2 of an integer in C#?
04:04 23 Jan 2012

How can I most efficiently count the number of bits required by an integer (log base 2) in C#? For example:

int bits = 1 + log2(100);

=> bits == 7
c# algorithm math bit-manipulation