STDC_BIT_CEIL(3)

πŸ“¦ version 15.1, in freebsd 15.1

πŸ’… STDC_BIT_CEIL(3) β€” like, the round-up-to-the-next-power-of-2 page, bestie

okay so this is STDC_BIT_CEIL(3) from the Library Functions Manual, and it is literally the "round up to the next power of 2" era and we are obsessed. come sit with me, this one's short and it ate. ✨


🌸 NAME 🌸

stdc_bit_ceil β€” round up to the next power of 2

no cap, that's the whole vibe. you hand it a number, it hands you back the next power of 2 going up. queen behavior. πŸ‘‘


πŸŽ€ 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(value)
stdc_bit_ceil(value);

like yes, there are five whole tiny functions plus the type-generic macro, and every single one of them is serving. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

so 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. six-letter lore, iykyk. 🌈

and the stdc_bit_ceil(value) type-generic macro? she's the main character β€” she picks the appropriate stdc_bit_ceil_type() function based on the type of value. literally does the matching for you so you don't have to. 🫢

ok but the way this is genuinely convenient β€” one name, five types, zero thoughts required. periodt.

⭐ RETURN VALUES ⭐

Returns value rounded up to the next power of 2. and if that value is not representable? you get 0 back. that's it, that's the whole answer. πŸ’€ (yes, 0 is the "nope, can't do it" signal here, so clock it.)


πŸ”₯ SEE ALSO πŸ”₯

the floor version is her sibling and yes you should read both, bestie. they're a package deal. πŸŽ€


πŸ’œ STANDARDS πŸ’œ

The stdc_bit_ceil_type() family of functions and the stdc_bit_ceil() type-generic macro conform to .

(yes, the citation in the page is literally just blank after "conform to" β€” not me forgetting, that's how it shipped πŸ™ˆ)


🌸 HISTORY 🌸

The stdc_bit_ceil_type() family of functions and the stdc_bit_ceil() type-generic macro were added in FreeBSD 15.1. she's new here and she's already iconic. ✨


πŸ‘‘ AUTHOR πŸ‘‘

Robert Clausecker <fuz@FreeBSD.org>

give her a round of applause fr fr 🫢


and that's the page!! tysm for reading, ily, go round some bits up πŸ’–

this cutie was brought to you by the Debian crew, dated November 9, 2025 β€” signing off πŸŽ€

πŸ“¦ where this page comes from
  • freebsd 15.1: base 15.1
  • πŸ“œ the page's license: BSD-2-Clause
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms