16 Jul
2010
16 Jul
'10
3:24 p.m.
AMDG Murilo Adriano Vasconcelos wrote:
2010/7/15 Steven Watanabe
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 implementations. I think ilog2 is better as it matches the convention used by logb and ilogb. In Christ, Steven Watanabe