STDC_BIT_WIDTH(3)

NAME
stdc_bit_width - find the first trailing one in an intege

SYNOPSIS
libc
#include <stdbit.h>
unsigned int
stdc_bit_width_uc(unsigned char value);
unsigned int
stdc_bit_width_us(unsigned short value);
unsigned int
stdc_bit_width_ui(unsigned int value);
unsigned int
stdc_bit_width_ul(unsigned long value);
unsigned int
stdc_bit_width_ull(unsigned long long value);
unsigned int
stdc_bit_width(value);

DESCRIPTION
The stdc_bit_width_type() family of functions returns the number of bits needed to represent 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. The stdc_bit_width(value) type-generic macro picks the appropriate stdc_bit_width_type() function based on the type of value.

Functions stdc_bit_width_ui(), stdc_bit_width_ul(), and stdc_bit_width_ull() are identical to 4.3BSD functions fls(3), flsl(3), and flsll(3) respectively, except for operating on unsigned instead of signed values.

RETURN VALUES
Returns the least number of bits needed to represent value. If value is zero, the return value is zero. Otherwise it is

SEE ALSO
bit_fls(3), fls(3), flsl(3), flsll(3), stdbit(3), stdc_count_leading_zeros(3), stdc_first_leading_one(3)

STANDARDS
The stdc_bit_width_type() family of functions and the stdc_bit_width() type-generic macro conform to isoC-2023.

HISTORY
The stdc_bit_width_type() family of functions and the stdc_bit_width() type-generic macro were added in FreeBSD 15.1.

AUTHOR
Robert Clausecker <fuz@FreeBSD.org>