Boost logo

Boost Users :

Subject: Re: [Boost-users] About naming of integer log in base 2
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2010-07-16 11:24:07


Murilo Adriano Vasconcelos wrote:
> 2010/7/15 Steven Watanabe <watanabesj_at_[hidden]>
>> log2 conflicts with the C++0x library which works with floating point
>> (and returns a double when it's given an integer)
> This is the point.

You mean you want log2 for integers to return an integer?
IMHO, this is wrong. The standard explicitly specifies what
should happen if an integer is passed to any of the cmath
functions. The standard only specifies that there shall be
sufficient extra overloads to accomplish this. If you use log2,
it is likely to result in either unexpected results or overload
ambiguities, possibly differing between standard library

I think ilog2 is better as it matches the convention used by
logb and ilogb.

In Christ,
Steven Watanabe

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