asteroidfodder
Re:Minimal examples of data structures and algorithms in Python
on Tuesday April 25, 2017 @02:27AM (#14191233)
Looks like count_bits loops infinitely if given a negative number.
The wiki (https://wiki.python.org/moin/BitwiseOperators) says:
Of course, Python doesn't use 8-bit numbers. It USED to use however many bits were native to your machine, but since that was non-portable, it has recently switched to using an INFINITE number of bits. Thus the number -5 is treated by bitwise operators as if it were written "...1111111111111111111011".