Hi,
 

Maybe, it depends on the relative cost of two: the reason for unchecked_factorial is that low-order factorials are often used inside the inner loop of a computation, where anything more expensive than a simple table lookup is out of the question (and the check can easily be moved outside the loop anyway).  Does the same thing apply here.... or is the cost of the check trivial compared to the bit manipulations?  I don't know the answers to these BTW, just some questions you might want to think about ;-)


Thank you John! 

I thought better and followed Paul's recommendations and implemented math::policies on ilog2() [0], and also changed the count_leading_zeros(T value) to return the size in bits of T when value is equal to 0 (all bits are leading 0's).

So I've added two ifs, but think that the design of the functions are better.

[0] - https://svn.boost.org/trac/boost/browser/sandbox/SOC/2010/bits_and_ints/boost/integer/ilog2.hpp?rev=64198
 
ilog2 isn't a bad name BTW, John.

 
I think ilog2 won.

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