---
name: "stdc_has_single_bit"
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_has_single_bit"
---

# stdc\_has\_single\_bit(3)

check for single bit set

## NAME

**stdc\_has\_single\_bit** – check for single bit set

## SYNOPSIS

Standard C Library (libc, -lc)

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

*bool*\

**stdc\_has\_single\_bit\_uc**(*unsigned char value*);

*bool*\

**stdc\_has\_single\_bit\_us**(*unsigned short value*);

*bool*\

**stdc\_has\_single\_bit\_ui**(*unsigned int value*);

*bool*\

**stdc\_has\_single\_bit\_ul**(*unsigned long value*);

*bool*\

**stdc\_has\_single\_bit\_ull**(*unsigned long long value*);

*bool*\

**stdc\_has\_single\_bit**(*value*);

## DESCRIPTION

The **stdc\_has\_single\_bit\_***type*() family of functions checks if there is exactly one bit set 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\_has\_single\_bit**(*value*) type-generic macro picks the appropriate **stdc\_has\_single\_bit\_***type*() function based on the type of *value*.

The functions in this family behave similarly to the **powerof2**(*value*) macro of ⟨sys/param.h⟩, but differ when *value* is zero: while **powerof2**() considers zero to be a power of two, **stdc\_has\_single\_bit**() does not.

## RETURN VALUES

Returns **true** if exactly one bit is set in *value*, otherwise returns **false**. I.e. the function determines if *value* is a power of two.

## SEE ALSO

[stdbit(3)](/stdbit/3.md), [stdc\_count\_ones(3)](/stdc_count_ones/3.md)

## STANDARDS

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

## HISTORY

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

## AUTHORS

Robert Clausecker ⟨*fuz@FreeBSD.org*⟩
