---
name: "stdc_first_trailing_one"
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_first_trailing_one"
---

# stdc\_first\_trailing\_one(3)

find the first trailing one in an integer

## NAME

**stdc\_first\_trailing\_one** – find the first trailing one in an integer

## SYNOPSIS

Standard C Library (libc, -lc)

**#include \<stdbit.h\>**

*unsigned* *int*\

**stdc\_first\_trailing\_one\_uc**(*unsigned char value*);

*unsigned* *int*\

**stdc\_first\_trailing\_one\_us**(*unsigned short value*);

*unsigned* *int*\

**stdc\_first\_trailing\_one\_ui**(*unsigned int value*);

*unsigned* *int*\

**stdc\_first\_trailing\_one\_ul**(*unsigned long value*);

*unsigned* *int*\

**stdc\_first\_trailing\_one\_ull**(*unsigned long long value*);

*unsigned* *int*\

**stdc\_first\_trailing\_one**(*value*);

## DESCRIPTION

The **stdc\_first\_trailing\_one\_***type*() family of functions returns the index of the least significant set bit 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. The **stdc\_first\_trailing\_one**(*value*) type-generic macro picks the appropriate **stdc\_first\_trailing\_one\_***type*() function based on the type of *value*.

Functions **stdc\_first\_trailing\_one\_ui**(), **stdc\_first\_trailing\_one\_ul**(), and **stdc\_first\_trailing\_one\_ull**() are identical to 4.3BSD functions [ffs(3)](/ffs/3.md), [ffsl(3)](/ffsl/3.md), and [ffsll(3)](/ffsll/3.md) respectively, except for operating on unsigned instead of signed values.

## RETURN VALUES

Returns the index of the least significant set bit in *value*. The bits are numbered such that the least significant bit has number 1, and the most significant bit has number **w** where **w** is the number of bits in the type of *value*. If no bits are set in *value* (i.e. *value* is zero), one is returned.

## SEE ALSO

[bit\_ffs(3)](/bit_ffs/3.md), [ffs(3)](/ffs/3.md), [ffsl(3)](/ffsl/3.md), [ffsll(3)](/ffsll/3.md), [stdbit(3)](/stdbit/3.md), [stdc\_first\_leading\_one(3)](/stdc_first_leading_one/3.md), [stdc\_first\_trailing\_zero(3)](/stdc_first_trailing_zero/3.md), [stdc\_trailing\_zeros(3)](/stdc_trailing_zeros/3.md)

## STANDARDS

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

## HISTORY

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

## AUTHORS

Robert Clausecker ⟨*fuz@FreeBSD.org*⟩
