---
name: "stdc_bit_width"
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_bit_width"
---

# stdc\_bit\_width(3)

find the first trailing one in an intege

## NAME

**stdc\_bit\_width** – find the first trailing one in an intege

## SYNOPSIS

Standard C Library (libc, -lc)

**#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)](/fls/3.md), [flsl(3)](/flsl/3.md), and [flsll(3)](/flsll/3.md) 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 1 +  log sub 2 italic value  .

## SEE ALSO

bit\_fls(3), [fls(3)](/fls/3.md), [flsl(3)](/flsl/3.md), [flsll(3)](/flsll/3.md), [stdbit(3)](/stdbit/3.md), stdc\_count\_leading\_zeros(3), [stdc\_first\_leading\_one(3)](/stdc_first_leading_one/3.md)

## STANDARDS

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

## HISTORY

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

## AUTHORS

Robert Clausecker ⟨*fuz@FreeBSD.org*⟩
