---
name: "stdc_count_zeros"
section: "3"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["freebsd"]
url: "https://new.carta.tech/stdc_count_zeros"
---

# stdc\_count\_zeros(3)

count the zeros in an integer

## NAME

**stdc\_count\_zeros** – count the zeros in an integer

## SYNOPSIS

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*);

## DESCRIPTION

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*.

## SEE ALSO

[stdbit(3)](/stdbit/3.md), [stdc\_count\_ones(3)](/stdc_count_ones/3.md)

## STANDARDS

The **stdc\_count\_zeros\_***type*() family of functions and the **stdc\_count\_zeros**() type-generic macro conform to ISO/IEC 9899:2024 (“ISO C23”).

## HISTORY

The **stdc\_count\_zeros\_***type*() family of functions and the **stdc\_count\_zeros**() type-generic macro were added in FreeBSD 15.1.

## AUTHORS

Robert Clausecker ⟨*fuz@FreeBSD.org*⟩
