stdc_count_zeros3
Count the zeros in an integer
Usage
Standard C Library (libc, -lc)
#include <stdbit.h>
unsigned int
stdc_count_zeros_uc(unsigned char value);
unsigned int
stdc_count_zeros_us(unsigned short value);
unsigned int
stdc_count_zeros_ui(unsigned int value);
unsigned int
stdc_count_zeros_ul(unsigned long value);
unsigned int
stdc_count_zeros_ull(unsigned long long value);
unsigned int
stdc_count_zeros(value);
Overview
The stdc_count_zeros_type() family of functions returns the number of bits set to 0 in value, where value is of type unsigned char, unsigned short, unsigned int, unsigned long, or unsigned long long for type being uc, us, ui, ul, or ull respectively. This is also known as the “population count” (popcount) or “Hamming weight” of the complement of value. The stdc_count_zeros(value) type-generic macro picks the appropriate stdc_count_zeros_type() function based on the type of value.
Return values
Returns the number of bits set to 0 in value.
Releases
2 releases since FreeBSD 15.1-RELEASE; the text changed 1 time.