STDC_FIRST_TRAILING_ZERO(3)

πŸ“¦ version 15.1, in freebsd 15.1

πŸ’… STDC_FIRST_TRAILING_ZERO πŸ’…

okay so bestie, this is a page from the Library Functions Manual and it's all about stdc_first_trailing_zero β€” find the first trailing zero in an integer ✨ no cap, it's simpler than it sounds.


πŸ¦‹ NAME πŸ¦‹

stdc_first_trailing_zero β€” find the first trailing zero in an integer πŸŽ€


✨ SYNOPSIS ✨

Standard C Library (libc, -lc)

#include <stdbit.h>

unsigned int
stdc_first_trailing_zero_uc(unsigned char value);

unsigned int
stdc_first_trailing_zero_us(unsigned short value);

unsigned int
stdc_first_trailing_zero_ui(unsigned int value);

unsigned int
stdc_first_trailing_zero_ul(unsigned long value);

unsigned int
stdc_first_trailing_zero_ull(unsigned long long value);

unsigned int
stdc_first_trailing_zero(value);

like, yes, that's a whole little family of them 🫢 each one is just the same thing wearing a different type's outfit:

  • stdc_first_trailing_zero_uc(unsigned char value) β€” the unsigned char one πŸ“
  • stdc_first_trailing_zero_us(unsigned short value) β€” the unsigned short one 🌸
  • stdc_first_trailing_zero_ui(unsigned int value) β€” the unsigned int one πŸ’œ
  • stdc_first_trailing_zero_ul(unsigned long value) β€” the unsigned long one πŸ¦‹
  • stdc_first_trailing_zero_ull(unsigned long long value) β€” the unsigned long long one πŸ‘‘
  • stdc_first_trailing_zero(value) β€” the type-generic macro, the main character of the group chat 🌈

πŸ’– DESCRIPTION πŸ’–

so the stdc_first_trailing_zero_type() family of functions returns the index of the least significant clear bit in value β€” and 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. it's giving "same function, five sizes" πŸ’…

and the stdc_first_trailing_zero(value) type-generic macro? she picks the appropriate stdc_first_trailing_zero_type() function based on the type of value. lowkey iconic, she just knows πŸŽ€


⭐ RETURN VALUES ⭐

returns the index of the least significant clear 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. πŸ”₯

and if no bits are clear in value (i.e. value is the bitwise complement of zero), then 0 is returned β€” yeah, that's the "nothing to see here" answer, zero, fr fr πŸ’€


🌸 SEE ALSO 🌸

go read those too bestie, they're friends of the family πŸ’œ


🌈 STANDARDS 🌈

the stdc_first_trailing_zero_type() family of functions and the stdc_first_trailing_zero() type-generic macro conform to . β€” yep, that's literally what the page says, it just stops there, the sentence ends and the standard's name is a no-show 😭 not me pointing at an empty spot, but okay, that's the manuscript, moving on 🫢


🧚 HISTORY 🧚

the stdc_first_trailing_zero_type() family of functions and the stdc_first_trailing_zero() type-generic macro were added in FreeBSD 15.1. slay, fairly recent, we love a fresh addition ✨


πŸ‘‘ AUTHOR πŸ‘‘

Robert Clausecker <fuz@FreeBSD.org> β€” thank you king, the bits are numbered correctly πŸ™Œ


and that's the whole page, bestie πŸ’– cute little sign-off: this one's from the Debian edition, dated November 9, 2025, and it lives at STDC_FIRST_TRAILING_ZERO(3) β€” go find yourself a clear bit, you got this πŸŽ€πŸ¦‹πŸŒ·

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