I was reading somewhere that:
The smallest integer larger than lg N is the number of bits required to represent N in binary, in the same way that the smallest integer larger than log10 N is the number of digits required to represent N in decimal.
The Java statement
for (lgN = 0; N > 0; lgN++, N /= 2) ;
is a simple way to compute the smallest integer larger than lg N
I maybe missing something here but how does the Java statement calculate the smallest integer larger than lg N?