FINDLSB(3G)

πŸ“¦
version 1.0~svn33624 Β· 4 versions
, in ubuntu jammy, ubuntu noble

πŸ’… FINDLSB β€” okay bestie, let's find that bit πŸ’…

Hi hello yes this is findLSB, a page from the 3G manual, and we are about to get intimately acquainted with the least significant bit that's chillin' at 1 in your integer. πŸ¦‹


✨ NAME ✨

findLSB β€” find the index of the least significant bit set to 1 in an integer


🌸 DECLARATION 🌸

Like, here's the vibe, literally the function signatures, do not touch a single character:

genIType findLSB(genIType value);

genIType findLSB(genUType value);

Two overloads, both iconic, both giving exactly what they need to give. πŸ‘‘


πŸŽ€ PARAMETERS πŸŽ€

  • value β€” the value whose bits we're scanning. That's it, that's the whole parameter. She's simple, she's effective. πŸ’–

✨ DESCRIPTION ✨

So findLSB returns the bit number of the least significant bit that is set to 1 in the binary representation of value. Basically: we're walking from the bottom up, looking for the first little 1 that says hi. πŸ”₯

And if value is zero? -1 will be returned. No bits are set, so there's nothing to find, and the function just tells you -1. Not a vibe, but it's honest. πŸ’€


πŸ‘‘ VERSION SUPPORT πŸ‘‘

Not every OpenGL Shading Language version was ready for this energy, so here's the receipts, one version at a time β€” function name findLSB:

  • 1.10 β€” - (nope)
  • 1.20 β€” - (nope)
  • 1.30 β€” - (nope)
  • 1.40 β€” - (nope)
  • 1.50 β€” - (nope)
  • 3.30 β€” - (nope)
  • 4.00 β€” βœ” (yes bestie)
  • 4.10 β€” βœ”
  • 4.20 β€” βœ”
  • 4.30 β€” βœ”
  • 4.40 β€” βœ”
  • 4.50 β€” βœ”

So like, 4.00 and onward? She ate. Everything before? Not invited to the function. πŸ™ˆ


πŸ¦‹ SEE ALSO πŸ¦‹

  • findMSB()

(yes, her more significant sister, go read that one too, iykyk πŸ’œ)


Copyright Β© 2011-2014 Khronos Group. This material may be distributed subject to the terms and conditions set forth in the Open Publication License, v 1.0, 8 June 1999. http://opencontent.org/openpub/.

Copyright Β© 2011-2014 Khronos Group


Okay that's the whole page, mwah, ily, go find some bits. This little number came from the [FIXME: source] crew and it's dated 01/03/2018 β€” FINDLSB(3G), periodt. 🫢✨

πŸ“¦ where this page comes from