STDC_FIRST_LEADING_ONE(3)
π STDC_FIRST_LEADING_ONE(3) β the stdc_first_leading_one glow-up
okay so bestie, this is page STDC_FIRST_LEADING_ONE(3) from the Library Functions Manual, and it's literally about finding the first leading one in an integer. yes, a one. the digit. in binary. we love a niche icon β¨
πΈ NAME πΈ
stdc_first_leading_one β find the first leading one in an integer
β¨ SYNOPSIS β¨
Standard C Library (libc, -lc)
#include <stdbit.h>
unsigned int
stdc_first_leading_one_uc(unsigned char value);
unsigned int
stdc_first_leading_one_us(unsigned short value);
unsigned int
stdc_first_leading_one_ui(unsigned int value);
unsigned int
stdc_first_leading_one_ul(unsigned long value);
unsigned int
stdc_first_leading_one_ull(unsigned long long value);
unsigned int
stdc_first_leading_one(value);
π DESCRIPTION π
The stdc_first_leading_one_type() family of functions returns the index of the most significant set bit in value, 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.
and then stdc_first_leading_one(value) β the type-generic macro β is like the friend who picks the right outfit for you π it picks the appropriate stdc_first_leading_one_type() function based on the type of value. no cap, it just knows.
π RETURN VALUES π
Returns the index of the most significant set bit in value.
The bits are numbered such that the most significant bit has number 1, and the least significant bit has number w where w is the number of bits in the type of value. so it's counting from the front like a true main character π
If no bits are set in value (i.e. value is zero), zero is returned. yes bestie, zero gets zero. that's just the vibe check it failed π
π¦ SEE ALSO π¦
π STANDARDS π
The stdc_first_leading_one_type() family of functions and the stdc_first_leading_one() type-generic macro conform to . β and yeah, that's genuinely how the page reads, the standard name got left on read π not me fixing it, that's exactly what it says.
π₯ HISTORY π₯
The stdc_first_leading_one_type() family of functions and the stdc_first_leading_one() type-generic macro were added in FreeBSD 15.1. fresh drop, honestly.
π AUTHOR π
Robert Clausecker <fuz@FreeBSD.org>
lowkey reminder: this whole vibe is Debian's page, datedNovember 9, 2025, and it'sSTDC_FIRST_LEADING_ONE(3)all the way down. slay π«Άπ
π¦ 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