Skip to content

Latest commit

 

History

History
12 lines (9 loc) · 473 Bytes

19355.new_feature.rst

File metadata and controls

12 lines (9 loc) · 473 Bytes

np.bit_count to compute the number of 1-bits in an integer

This new function counts the number of 1-bits in a number. These work on all the numpy integer types, as well as the builtin arbitrary-precision Decimal and long types.

>>> a = np.array([2**i - 1 for i in range(16)])
>>> np.bit_count(a)
array([ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15])