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-20 10:39:25


> 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

[0] -

> ilog2 isn't a bad name BTW, John.
I think ilog2 won.


Murilo Adriano Vasconcelos

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