Better HN
topnewbestaskshowjobs
Log inSign up

asteroidfodder

2 karma · joined Apr 25, 2017 (9y ago) · 1 submissions

Submissions

comment 9y ago · link · parent

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".