Skip to main content

popcount

Function popcount 

Source
pub fn popcount(builder: &mut CircuitBuilder, input: Wire) -> Wire
Expand description

Computes the population count (number of 1-bits) of a 64-bit word.

This function implements the SWAR algorithm to efficiently count bits using parallel operations within a single 64-bit register.

§Arguments

  • builder - The circuit builder to add constraints to
  • input - Wire containing the 64-bit value to count bits in

§Returns

  • Wire containing the popcount result (value between 0 and 64)