@popCount

@popCount

@popCount(comptime T: type, integer: T)

Counts the number of bits set in an integer.

If integer is known at comptime, the return type is comptime_int. Otherwise, the return type is an unsigned integer with the minimum number of bits that can represent the bit count of the integer type.

See also:

  • @ctz
  • @clz