Boost logo

Boost Users :

Subject: Re: [Boost-users] About naming of integer log in base 2
From: Murilo Adriano Vasconcelos (muriloufg_at_[hidden])
Date: 2010-07-17 13:52:50


> 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


What if I make 2 versions of ilog2:

   - unchecked_ilog2(T value) - don't checks the input value
   - ilog2(T value) - returns -1 if value == 0 else returns

Following the line of:


I will maintain the name ilog2 for now.


Murilo Adriano Vasconcelos

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at