STDC_BIT_CEIL(3) FreeBSD Library Functions Manual STDC_BIT_CEIL(3)
NAME
stdc_bit_ceil - round up to the next power of 2
SYNOPSIS
/* -lc */
#include <stdbit.h>
unsigned char
stdc_bit_ceil_uc(unsigned char value);
unsigned short
stdc_bit_ceil_us(unsigned short value);
unsigned int
stdc_bit_ceil_ui(unsigned int value);
unsigned long
stdc_bit_ceil_ul(unsigned long value);
unsigned long long
stdc_bit_ceil_ull(unsigned long long value);
typeof(value)
stdc_bit_ceil(value);
DESCRIPTION
The stdc_bit_ceil_type() family of functions rounds value up to the next
power of 2, 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. The stdc_bit_ceil(value) type-generic macro
picks the appropriate stdc_bit_ceil_type() function based on the type of
value.
RETURN VALUES
Returns value round up to the next power of 2. If this value is not
representable, 0 is returned.
SEE ALSO
stdbit(3), stdc_bit_floor(3)
STANDARDS
The stdc_bit_ceil_type() family of functions and the stdc_bit_ceil()
type-generic macro conform to ISO/IEC 9899:2024 ("ISO C23").
HISTORY
The stdc_bit_ceil_type() family of functions and the stdc_bit_ceil()
type-generic macro were added in FreeBSD 15.1.
AUTHOR
Robert Clausecker <fuz@FreeBSD.org>
FreeBSD 15.1-STABLE-HBSD November 9, 2025 STDC_BIT_CEIL(3)