|
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
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 doesnt 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:
- unchecked_ilog2(T value) - don't checks the input value
- ilog2(T value) - returns -1 if value == 0 else returns
unchecked_ilog2(value)
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
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net