Re: how to get the thighest bit position in big integers?



On Oct 29, 4:16 pm, Glenn Linderman <v+pyt...@xxxxxxxxxxxx> wrote:
On approximately 10/29/2008 11:51 AM, came the following characters from
the keyboard of Mensanator:

or in 2.6

print 'highest bit position: %d' % (len(bin(3328)[2:])-1)

highest bit position: 11

This works, but where is it documented?  

Good question. Now that I think about it, I believe I learned of
it here, never saw it in the docs.

Searching the Python 2.6 docs
for bin found lots of things that start with bin, but none of them were
bin.  Searching the builtins page manual didn't find it.  Is this a bug
in the documentation?

Well ,it's mentioned in "What's new in Python 2.6":
<quote>
Python 3.0 adds several new built-in functions
and change the semantics of some existing built-ins.
Entirely new functions such as bin() have simply
been added to Python 2.6, but existing built-ins
haven’t been changed;
</quote>

You would think when you add a new function, you would
also add it's documentation, but maybe that was an
oversight. I don't have 3.0, but maybe it can be found
in that set of docs.


--
Glenn --http://nevcal.com/
===========================
A protocol is complete when there is nothing left to remove.
-- Stuart Cheshire, Apple Computer, regarding Zero Configuration Networking

.



Relevant Pages

  • Re: Finding installed package files
    ... for making installation information more easily accessible? ... >> somewhere where more information about the key parts of the package ... >> As an example I installed the latest Python on Fedora 3. ... what one would expect is a form of help documentation much more integrated ...
    (alt.os.linux.redhat)
  • Re: Do you feel bad because of the Python docs?
    ... "The Python documentation is bad, ... It is valuable to contrast and compare the PHP and Python docs: ... One of the problems with "fixing" the Python reference docs ...
    (comp.lang.python)
  • Re: Bitching about the documentation...
    ... > a language need complaints about the language? ... To give potential adopters of Python a more even handed view ... but sometimes "constructive criticism" means ... I have found Python's documentation to generally be excellent. ...
    (comp.lang.python)
  • Re: My Python annoyances
    ... incomplete documentation, a maze of little platform-specific quirks to ... Python base classes have changed behavior. ... perhaps the best introduction to the language when it was written. ... I filed a bug report. ...
    (comp.lang.python)
  • Re: My Python annoyances
    ... incomplete documentation, a maze of little platform-specific quirks to ... Python base classes have changed behavior. ... perhaps the best introduction to the language when it was written. ... I filed a bug report. ...
    (comp.lang.python)