bigIntPopCount
bigIntPopCount(
value):number
Defined in: packages/core/src/big-int/bit/pop-count.ts:18
Counts the set bits across a bigint of any width (Hamming weight), where
popCount64 stops at the low 64.
The magnitude is counted, so a negative value answers the same as its absolute value. Two’s complement would otherwise make every negative number infinitely wide, which is not a count anyone can use.
O(n / 64) iterations for an n-bit value, each one a constant-time SWAR reduction, rather than the O(n) shift-and-test a per-bit loop costs.
Parameters
Section titled “Parameters”bigint
The value to count.
Returns
Section titled “Returns”number
The number of set bits in |value|.