Hi,

The initial intent was log2(0) = -1, you can check if your compiler isn't GCC that count_leading_zeros(T(0)) is always sizeof(T) * 8 (all bits are leading zeros). 

But one of the intents of this implementation is performance so, using compiler optimized functions is desired.

 

So the function to be analyzed in this case is count_leading_zeros.

 

I can see the ‘need for speed’, but that doesn’t change the argument for using policies to allow users to control at compile time how exceptional situations are handled.  Policies should have no effect on run time, apart from any checks implied by the chosen policy. 

 

Paul


Paul:
 
What if I make 2 versions of ilog2:
Following the line of:
http://www.boost.org/doc/libs/1_43_0/libs/math/doc/sf_and_dist/html/math_toolkit/special/factorials/sf_factorial.html

Steven:

I will maintain the name ilog2 for now. 


Best,

--
Murilo Adriano Vasconcelos
http://murilo.wordpress.com