[stdbit.h.syn]

# 22 General utilities library [[utilities]](./#utilities)

## 22.12 Header <stdbit.h> synopsis [stdbit.h.syn]

[ð](#header:%3cstdbit.h%3e)

// all freestanding#define __STDC_VERSION_STDBIT_H__ 202311L#define __STDC_ENDIAN_BIG__ *see below*#define __STDC_ENDIAN_LITTLE__ *see below*#define __STDC_ENDIAN_NATIVE__ *see below*unsigned int [stdc_leading_zeros_uc](#lib:stdc_leading_zeros_uc "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(unsigned char value);unsigned int [stdc_leading_zeros_us](#lib:stdc_leading_zeros_us "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(unsigned short value);unsigned int [stdc_leading_zeros_ui](#lib:stdc_leading_zeros_ui "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(unsigned int value);unsigned int [stdc_leading_zeros_ul](#lib:stdc_leading_zeros_ul "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(unsigned long int value);unsigned int [stdc_leading_zeros_ull](#lib:stdc_leading_zeros_ull "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(unsigned long long int value);template<class T> *see below* [stdc_leading_zeros](#lib:stdc_leading_zeros "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(T value);

unsigned int [stdc_leading_ones_uc](#lib:stdc_leading_ones_uc "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(unsigned char value);unsigned int [stdc_leading_ones_us](#lib:stdc_leading_ones_us "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(unsigned short value);unsigned int [stdc_leading_ones_ui](#lib:stdc_leading_ones_ui "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(unsigned int value);unsigned int [stdc_leading_ones_ul](#lib:stdc_leading_ones_ul "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(unsigned long int value);unsigned int [stdc_leading_ones_ull](#lib:stdc_leading_ones_ull "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(unsigned long long int value);template<class T> *see below* [stdc_leading_ones](#lib:stdc_leading_ones "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(T value);

unsigned int [stdc_trailing_zeros_uc](#lib:stdc_trailing_zeros_uc "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(unsigned char value);unsigned int [stdc_trailing_zeros_us](#lib:stdc_trailing_zeros_us "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(unsigned short value);unsigned int [stdc_trailing_zeros_ui](#lib:stdc_trailing_zeros_ui "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(unsigned int value);unsigned int [stdc_trailing_zeros_ul](#lib:stdc_trailing_zeros_ul "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(unsigned long int value);unsigned int [stdc_trailing_zeros_ull](#lib:stdc_trailing_zeros_ull "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(unsigned long long int value);template<class T> *see below* [stdc_trailing_zeros](#lib:stdc_trailing_zeros "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(T value);

unsigned int [stdc_trailing_ones_uc](#lib:stdc_trailing_ones_uc "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(unsigned char value);unsigned int [stdc_trailing_ones_us](#lib:stdc_trailing_ones_us "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(unsigned short value);unsigned int [stdc_trailing_ones_ui](#lib:stdc_trailing_ones_ui "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(unsigned int value);unsigned int [stdc_trailing_ones_ul](#lib:stdc_trailing_ones_ul "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(unsigned long int value);unsigned int [stdc_trailing_ones_ull](#lib:stdc_trailing_ones_ull "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(unsigned long long int value);template<class T> *see below* [stdc_trailing_ones](#lib:stdc_trailing_ones "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(T value);

unsigned int [stdc_first_leading_zero_uc](#lib:stdc_first_leading_zero_uc "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(unsigned char value);unsigned int [stdc_first_leading_zero_us](#lib:stdc_first_leading_zero_us "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(unsigned short value);unsigned int [stdc_first_leading_zero_ui](#lib:stdc_first_leading_zero_ui "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(unsigned int value);unsigned int [stdc_first_leading_zero_ul](#lib:stdc_first_leading_zero_ul "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(unsigned long int value);unsigned int [stdc_first_leading_zero_ull](#lib:stdc_first_leading_zero_ull "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(unsigned long long int value);template<class T> *see below* [stdc_first_leading_zero](#lib:stdc_first_leading_zero "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(T value);

unsigned int [stdc_first_leading_one_uc](#lib:stdc_first_leading_one_uc "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(unsigned char value);unsigned int [stdc_first_leading_one_us](#lib:stdc_first_leading_one_us "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(unsigned short value);unsigned int [stdc_first_leading_one_ui](#lib:stdc_first_leading_one_ui "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(unsigned int value);unsigned int [stdc_first_leading_one_ul](#lib:stdc_first_leading_one_ul "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(unsigned long int value);unsigned int [stdc_first_leading_one_ull](#lib:stdc_first_leading_one_ull "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(unsigned long long int value);template<class T> *see below* stdc_first_leading_one(T value);

unsigned int [stdc_first_trailing_zero_uc](#lib:stdc_first_trailing_zero_uc "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(unsigned char value);unsigned int [stdc_first_trailing_zero_us](#lib:stdc_first_trailing_zero_us "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(unsigned short value);unsigned int [stdc_first_trailing_zero_ui](#lib:stdc_first_trailing_zero_ui "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(unsigned int value);unsigned int [stdc_first_trailing_zero_ul](#lib:stdc_first_trailing_zero_ul "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(unsigned long int value);unsigned int [stdc_first_trailing_zero_ull](#lib:stdc_first_trailing_zero_ull "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(unsigned long long int value);template<class T> *see below* stdc_first_trailing_zero(T value);

unsigned int [stdc_first_trailing_one_uc](#lib:stdc_first_trailing_one_uc "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(unsigned char value);unsigned int [stdc_first_trailing_one_us](#lib:stdc_first_trailing_one_us "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(unsigned short value);unsigned int [stdc_first_trailing_one_ui](#lib:stdc_first_trailing_one_ui "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(unsigned int value);unsigned int [stdc_first_trailing_one_ul](#lib:stdc_first_trailing_one_ul "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(unsigned long int value);unsigned int [stdc_first_trailing_one_ull](#lib:stdc_first_trailing_one_ull "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(unsigned long long int value);template<class T> *see below* stdc_first_trailing_one(T value);

unsigned int [stdc_count_zeros_uc](#lib:stdc_count_zeros_uc "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(unsigned char value);unsigned int [stdc_count_zeros_us](#lib:stdc_count_zeros_us "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(unsigned short value);unsigned int [stdc_count_zeros_ui](#lib:stdc_count_zeros_ui "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(unsigned int value);unsigned int [stdc_count_zeros_ul](#lib:stdc_count_zeros_ul "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(unsigned long int value);unsigned int [stdc_count_zeros_ull](#lib:stdc_count_zeros_ull "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(unsigned long long int value);template<class T> *see below* [stdc_count_zeros](#lib:stdc_count_zeros "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(T value);

unsigned int [stdc_count_ones_uc](#lib:stdc_count_ones_uc "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(unsigned char value);unsigned int [stdc_count_ones_us](#lib:stdc_count_ones_us "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(unsigned short value);unsigned int [stdc_count_ones_ui](#lib:stdc_count_ones_ui "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(unsigned int value);unsigned int [stdc_count_ones_ul](#lib:stdc_count_ones_ul "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(unsigned long int value);unsigned int [stdc_count_ones_ull](#lib:stdc_count_ones_ull "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(unsigned long long int value);template<class T> *see below* stdc_count_ones(T value);

bool [stdc_has_single_bit_uc](#lib:stdc_has_single_bit_uc "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(unsigned char value);bool [stdc_has_single_bit_us](#lib:stdc_has_single_bit_us "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(unsigned short value);bool [stdc_has_single_bit_ui](#lib:stdc_has_single_bit_ui "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(unsigned int value);bool [stdc_has_single_bit_ul](#lib:stdc_has_single_bit_ul "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(unsigned long int value);bool [stdc_has_single_bit_ull](#lib:stdc_has_single_bit_ull "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(unsigned long long int value);template<class T> bool [stdc_has_single_bit](#lib:stdc_has_single_bit "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(T value);

unsigned int [stdc_bit_width_uc](#lib:stdc_bit_width_uc "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(unsigned char value);unsigned int [stdc_bit_width_us](#lib:stdc_bit_width_us "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(unsigned short value);unsigned int [stdc_bit_width_ui](#lib:stdc_bit_width_ui "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(unsigned int value);unsigned int [stdc_bit_width_ul](#lib:stdc_bit_width_ul "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(unsigned long int value);unsigned int [stdc_bit_width_ull](#lib:stdc_bit_width_ull "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(unsigned long long int value);template<class T> *see below* [stdc_bit_width](#lib:stdc_bit_width "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(T value);

unsigned char [stdc_bit_floor_uc](#lib:stdc_bit_floor_uc "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(unsigned char value);unsigned short [stdc_bit_floor_us](#lib:stdc_bit_floor_us "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(unsigned short value);unsigned int [stdc_bit_floor_ui](#lib:stdc_bit_floor_ui "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(unsigned int value);unsigned long int [stdc_bit_floor_ul](#lib:stdc_bit_floor_ul "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(unsigned long int value);unsigned long long int [stdc_bit_floor_ull](#lib:stdc_bit_floor_ull "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(unsigned long long int value);template<class T> T [stdc_bit_floor](#lib:stdc_bit_floor "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(T value);

unsigned char [stdc_bit_ceil_uc](#lib:stdc_bit_ceil_uc "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(unsigned char value);unsigned short [stdc_bit_ceil_us](#lib:stdc_bit_ceil_us "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(unsigned short value);unsigned int [stdc_bit_ceil_ui](#lib:stdc_bit_ceil_ui "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(unsigned int value);unsigned long int [stdc_bit_ceil_ul](#lib:stdc_bit_ceil_ul "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(unsigned long int value);unsigned long long int [stdc_bit_ceil_ull](#lib:stdc_bit_ceil_ull "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(unsigned long long int value);template<class T> T [stdc_bit_ceil](#lib:stdc_bit_ceil "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]")(T value);

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L16167)

For a function template whose return type is not specified above,
the return type is
an implementation-defined unsigned integer type
large enough to represent all possible result values[.](#1.sentence-1)

Each function template has the same semantics
as the corresponding type-generic function with the same name
specified in ISO/IEC 9899:2024, 7.18[.](#1.sentence-2)

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L16176)

*Mandates*: T is an unsigned integer type[.](#2.sentence-1)

[3](#3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L16180)

Otherwise,
the contents and meaning of the header [<stdbit.h>](#header:%3cstdbit.h%3e "22.12 Header <stdbit.h> synopsis [stdbit.h.syn]") are the same as
the C standard library header <stdbit.h>[.](#3.sentence-1)

See also: ISO/IEC 9899:2024, 7.18
