bit count or bit set && Python3
Christian Heimes
christian at python.org
Thu Oct 25 11:25:47 EDT 2012
More information about the Python-list mailing list
Thu Oct 25 11:25:47 EDT 2012
- Previous message (by thread): bit count or bit set && Python3
- Next message (by thread): bit count or bit set && Python3
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Am 25.10.2012 16:47, schrieb Charles Hixson:
> In Python3 is there any good way to count the number of on bits in an
> integer (after an & operation)?
Simple, easy, faster than a Python loop but not very elegant:
bin(number).count("1")
Christian
- Previous message (by thread): bit count or bit set && Python3
- Next message (by thread): bit count or bit set && Python3
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list