Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Doc: use positive example, mention population count
  • Loading branch information
mdickinson committed May 27, 2020
commit b87f1621aea6152743be0aff4fb68bcb707b7932
9 changes: 6 additions & 3 deletions Doc/library/stdtypes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -481,13 +481,16 @@ class`. In addition, it provides a few more methods:
.. method:: int.bit_count()

Return the number of ones in the binary representation of the absolute
Comment thread
mdickinson marked this conversation as resolved.
value of the integer::
value of the integer. This is also known as the population count.
Example::

>>> n = -19
>>> n = 19
>>> bin(n)
'-0b10011'
'0b10011'
>>> n.bit_count()
3
>>> (-n).bit_count()
3

Equivalent to::

Expand Down