Boost logo

Boost Users :

Subject: Re: [Boost-users] About naming of integer log in base 2
From: John Maddock (boost.regex_at_[hidden])
Date: 2010-07-18 04:37:50


>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

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 ;-)

ilog2 isn't a bad name BTW, John.


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