This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mark.dickinson
Recipients fredrikj, loewis, mark.dickinson, rhettinger
Date 2008-08-18.21:28:46
SpamBayes Score 3.328305e-06
Marked as misclassified No
Message-id <>
> In every case I can think of, I've wanted (0).numbits() to be 0.

Me too, in most cases, though I've encountered the occasional case where 
raising ValueError would be more appropriate and would catch some bugs 
that might otherwise pass silently.

So I agree that (0).numbits() should be 0, but I think there's enough 
potential ambiguity that there should be a sentence in the documentation  
making this explicit.  Two of the most obvious (wrong) formulas for 
numbits are: (1) numbits(n) = ceiling(log_2(n)), and (2) numbits(n) = 
len(bin(n))-2, but neither of these formulas gives the right result for 
0, or for negative numbers for that matter.

> The explanation in the docstring can probably be improved. What other 
documentation is needed (where)?

The docstring looked okay to me.  There should be more comprehensive 
ReST documentation in the Doc/ directory somewhere, probably in 
Date User Action Args
2008-08-18 21:28:48mark.dickinsonsetrecipients: + mark.dickinson, loewis, rhettinger, fredrikj
2008-08-18 21:28:47mark.dickinsonsetmessageid: <>
2008-08-18 21:28:47mark.dickinsonlinkissue3439 messages
2008-08-18 21:28:46mark.dickinsoncreate