![]() |
|
|
+ Search |
![]()
|
Jul 5th, 2000 10:00
Nathan Wallace, unknown unknown, Hans Nowak, Snippet 104, Klaus Alexander Seistrup
"""
Packages: maths.bit_twiddling
"""
"""
G'day mates.
Here's a snippet for the repository:
"""
# The function bitcount() will count the number
# of bits in a number, iterating at most as many
# times as the number of bits.
#
def bitcount(x):
n = 0
while x:
x = x & (x-1)
n = n + 1
# end while
return n
# end def bitcount