STDC_LEADING_ONES(3)

πŸ“¦ version 15.1, in freebsd 15.1

πŸŽ€ STDC_LEADING_ONES(3) πŸŽ€

Library Functions Manual? More like library functions bestie manual πŸ’– okay so welcome to the group chat, we're learning how to count leading ones and it's lowkey iconic.


🌸 NAME 🌸

stdc_leading_ones β€” find the number of leading ones in an integer πŸ’…


✨ SYNOPSIS ✨

Link the Standard C Library: Standard C Library (libc, -lc). Header first, bestie: #include <stdbit.h>.

unsigned int
stdc_leading_ones_uc(unsigned char value);

unsigned int
stdc_leading_ones_us(unsigned short value);

unsigned int
stdc_leading_ones_ui(unsigned int value);

unsigned int
stdc_leading_ones_ul(unsigned long value);

unsigned int
stdc_leading_ones_ull(unsigned long long value);

unsigned int
stdc_leading_ones(value);

πŸ¦‹ DESCRIPTION πŸ¦‹

Okay so the stdc_leading_ones_type() family of functions returns the number of leading ones in value ✨. Here value is of type unsigned char, unsigned short, unsigned int, unsigned long, or unsigned long long, and type is uc, us, ui, ul, or ull respectively πŸ’….

The stdc_leading_ones(value) type-generic macro is the main character here: it picks the appropriate stdc_leading_ones_type() function based on the type of value 🫢. No cap, it just knows.


πŸ’– RETURN VALUES πŸ’–

Returns the number of leading ones in value. If value is all ones, the total number of bits in the type of value is returned πŸ”₯. So bestie, if it's literally all 1s, you get the whole bit-width back.


🌈 SEE ALSO 🌈

Go sip on those too, they're all in the same friend group πŸ’œ


⭐ STANDARDS ⭐

The stdc_leading_ones_type() family of functions and the stdc_leading_ones() type-generic macro conform to . πŸ’€ (That's what the page says, don't come for me.)


πŸ“ HISTORY πŸ“

The stdc_leading_ones_type() family of functions and the stdc_leading_ones() type-generic macro were added in FreeBSD 15.1 ✨ periodt.


πŸ‘‘ AUTHOR πŸ‘‘

Robert Clausecker <fuz@FreeBSD.org> 🫢


πŸ’– Source/version: Debian β€” date: November 9, 2025 πŸ’–

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