STDC_BIT_FLOOR(3)

πŸ“¦ version 15.1, in freebsd 15.1

✨ STDC_BIT_FLOOR(3) β€” your new fave libc page, section 3, library functions manual, mwah πŸ’…

okay so bestie, buckle up, because this one is genuinely adorable. we're talking about stdc_bit_floor from the Standard C Library, aka libc, linked with -lc, and it's a whole little family of functions that round your number down to the previous power of 2. that's the vibe. πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

here's the whole squad, look at them:

#include <stdbit.h>

unsigned char
stdc_bit_floor_uc(unsigned char value);

unsigned short
stdc_bit_floor_us(unsigned short value);

unsigned int
stdc_bit_floor_ui(unsigned int value);

unsigned long
stdc_bit_floor_ul(unsigned long value);

unsigned long long
stdc_bit_floor_ull(unsigned long long value);

typeof(value)
stdc_bit_floor(value);

no cap, that's the entire lineup. one for every size of unsigned int energy. πŸ”₯


πŸ’– DESCRIPTION πŸ’–

so the stdc_bit_floor_type() family of functions rounds value down to the previous power of 2. periodt. ✨

and value can be any of these types:

  • unsigned char β†’ that's type = uc πŸ“
  • unsigned short β†’ type = us 🌸
  • unsigned int β†’ type = ui πŸ¦‹
  • unsigned long β†’ type = ul πŸ’œ
  • unsigned long long β†’ type = ull πŸ‘‘

and then there's stdc_bit_floor(value), the type-generic macro, which is giving main character energy fr fr β€” it just looks at the type of value and picks the appropriate stdc_bit_floor_type() function for you. you don't even have to think about it. it just knows. 😭🫢


🌈 RETURN VALUES 🌈

it returns value rounded down to the previous power of 2. simple, iconic, no notes.

and if value is equal to zero? zero is returned. zero in, zero out, the most honest relationship you'll ever have. πŸ’€


πŸ”₯ SEE ALSO πŸ”₯

go give these besties some love too:


⭐ STANDARDS ⭐

The stdc_bit_floor_type() family of functions and the stdc_bit_floor() type-generic macro conform to .


🧚 HISTORY 🧚

The stdc_bit_floor_type() family of functions and the stdc_bit_floor() type-generic macro were added in FreeBSD 15.1. so they're lowkey new-ish, freshly dropped, and honestly? obsessed. πŸŽ€


πŸ‘‘ AUTHOR πŸ‘‘

Robert Clausecker <fuz@FreeBSD.org> β€” thank you for your service, legend πŸ«‘πŸ’–


and that's the page!! mwah πŸ’‹ this was Debian, dated November 9, 2025, signing off β€” STDC_BIT_FLOOR(3) forever, iykyk πŸŒΈβœ¨πŸ¦‹

πŸ“¦ 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