---
name: "stdc_bit_ceil"
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_ceil"
---

# stdc\_bit\_ceil(3)

round up to the next power of 2

## NAME

**stdc\_bit\_ceil** – round up to the next power of 2

## SYNOPSIS

Standard C Library (libc, -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* *Ns* *Pq* *Em* *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)](/stdbit/3.md), [stdc\_bit\_floor(3)](/stdc_bit_floor/3.md)

## 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.

## AUTHORS

Robert Clausecker ⟨*fuz@FreeBSD.org*⟩
