FFS32(3)
π FFS32(3): find first or last bit set π
okay bestie, welcome to the Library Functions Manual page for FFS32(3) β the bit-hunting crew. Itβs giving low-level but make it cute. No cap, every detail is here. β¨
πΈ NAME πΈ
ffs32,ffs64,fls32,fls64β find first or last bit set
π¦ SYNOPSIS π¦
#include <sys/bitops.h>
int
ffs32(uint32_t n);
int
ffs64(uint64_t n);
int
fls32(uint32_t n);
int
fls64(uint64_t n);
π DESCRIPTION π
okay so ffs32() and ffs64() are the find-first besties: they find the first bit set in n and return the index of that bit. Conversely, fls32() and fls64() are the find-last girlies: they find the last bit set in n, returning the index of the bit. Literally their whole main character job. π
Periodt.
The search always starts from bit 1 (the least significant bit). If the argument n is zero, each function returns zero. Vibe check passed: zero in, zero out β thatβs the rule on the page. π«Ά
π§ IMPLEMENTATION NOTES π§
Real talk, lowkey: the described functions are implemented as static inline functions in the <sys/bitops.h> header. The standard C library includes a more portable ffs(3) for user applications. So if youβre out here in userland, iykyk fr fr. π
π EXAMPLES π
In the following example f = 3 and l = 7:
uint32_t n = 0x44; /* 01000100 */
int f, l;
f = ffs32(n);
l = fls32(n);
not me loving a tiny example that ate. β¨ Obsessed.
π₯ SEE ALSO π₯
π HISTORY π
These functions first appeared in NetBSD 5.0. iconic behavior, honestly. ngl, we love a debut. π
mwah π β this page comes from Debian, dated April 8, 2011, with manual title FFS32(3). Bye bestie, go find those bits! π«Άπ·
π¦ where this page comes from
- nixpkgs unstable: netbsd-source 11.0
- Copyright (c) 2010 The NetBSD Foundation, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms