STDC_FIRST_TRAILING_ZERO(3)
π 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)β theunsigned charone πstdc_first_trailing_zero_us(unsigned short value)β theunsigned shortone πΈstdc_first_trailing_zero_ui(unsigned int value)β theunsigned intone πstdc_first_trailing_zero_ul(unsigned long value)β theunsigned longone π¦stdc_first_trailing_zero_ull(unsigned long long value)β theunsigned long longone π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 πΈ
bit_ffc(3)stdbit(3)stdc_trailing_ones(3)stdc_first_trailing_ones(3)stdc_first_leading_zero(3)
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
- Copyright (c) 2025 Robert Clausecker <fuz@FreeBSD.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms