From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Murilo Adriano Vasconcelos Sent: Wednesday, July 14, 2010 9:04 PM To: boost-users@lists.boost.org Subject: [Boost-users] About naming of integer log in base 2 Hi all, I implemented a function [0] wich computes the logarithm in base two of integers and want to know what naming is most appropriated: ilog2 or simply log2 [0] - http://svn.boost.org/svn/boost/sandbox/SOC/2010/bits_and_ints/boost/integer/... My instinct is for log2 so it might be specialised for floating point too. Glancing at your code, I note you don't explicitly check that type T is integer (but perhaps is_signed does that?) But I feel that * If `value` is equal to 0, the value returned is undefined may be evil in some peoples opinion. Of course it is always a vexed question what to do for the corner cases like this. I am sure that this sort of issue will raise its ugly head for other functions. You might like to consider making problem cases 'policy controlled'. In the Boost.Math package John Maddock went to the trouble of providing a way of letting users controlling what happens for cases like this. (He retrofitted policies, so you don't have to do it immediately - but doing it will focus your mind on the possible corner cases). If you read the math docs, perhaps the pdf at http://boost.cowic.de/rc/pdf/math.pdf or the download from source, and see the section on Policies you will see what it being suggested, and some examples. You might return zero, or ? or throw an exception? You can consult and see if there is a consensus on the default policy. At least it may reduce the discussion (Boosters are really good at that ;-) on what *should* happen, if you can say "You *can* make it do what you want." Paul --- Paul A. Bristow Prizet Farmhouse Kendal, UK LA8 8AB +44 1539 561830, mobile +44 7714330204 pbristow@hetp.u-net.com