intTools: Tools for working with integer values

fontTools.misc.intTools.bit_count(self, /)

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
fontTools.misc.intTools.bit_indices(v)[source]

Return list of indices where bits are set, 0 being the index of the least significant bit.

>>> bit_indices(0b101)
[0, 2]
fontTools.misc.intTools.popCount(self, /)

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3