FINDMSB(3G)

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

✨ NAME ✨

findMSB β€” bestie, this is the one that finds the index of the most significant bit set to 1 in an integer. πŸ’…

It lives in the 3G section of the manual, so if you ever see FINDMSB(3G) floating around, that's her, that's the queen. πŸ‘‘


🌸 DECLARATION 🌸

Okay so here's the whole vibe, signature-wise β€” two overloads, one for signed, one for unsigned:

genIType findMSB(genIType value);

genIType findMSB(genUType value);

Not me being obsessed with a two-line function. 😭


πŸŽ€ PARAMETERS πŸŽ€

  • value β€” the value whose bits you want to scan. That's it, that's the whole input, she takes one argument and she serves. 🫢

πŸ’– DESCRIPTION πŸ’–

So like, findMSB returns the bit number of the most significant bit that is set to 1 in the binary representation of value. ✨

For positive integers, the result will be the bit number of the most significant bit that is set to 1. Slay, straightforward, no notes.

For negative integers, the result will be the bit number of the most significant bit set to 0. Yeah, plot twist, but that's literally what it says. πŸ™ˆ

And for a value of zero or negative 1, -1 will be returned. So like, if you get a -1 back, bestie, that's not an error code, that's just the answer for those two specific inputs. 😌


🌈 VERSION SUPPORT 🌈

Here's the receipts on which OpenGL Shading Language versions actually have her. Look at the glow-up from 4.00 onwards. πŸ’€βœ¨

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚          β”‚        OpenGL Shading Language Version                                            β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€
β”‚ Function β”‚ 1.10 β”‚ 1.20 β”‚ 1.30 β”‚ 1.40 β”‚ 1.50 β”‚ 3.30 β”‚ 4.00 β”‚ 4.10 β”‚ 4.20 β”‚ 4.30 β”‚ 4.40 β”‚ 4.50 β”‚
β”‚ Name     β”‚      β”‚      β”‚      β”‚      β”‚      β”‚      β”‚      β”‚      β”‚      β”‚      β”‚      β”‚      β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€
β”‚ findMSB  β”‚  -   β”‚  -   β”‚  -   β”‚  -   β”‚  -   β”‚  -   β”‚  βœ”   β”‚  βœ”   β”‚  βœ”   β”‚  βœ”   β”‚  βœ”   β”‚  βœ”   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”˜

So the tea is: dashes all the way through 1.10, 1.20, 1.30, 1.40, 1.50 and 3.30, and then checkmarks from 4.00 through 4.50. Periodt. πŸ¦‹


🧚 SEE ALSO 🧚

  • findLSB()

Her sister function! The other end of the bit. Go say hi. πŸ’œ


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


And that's the whole page, bestie β€” originally hanging out under [FIXME: manual] up top and [FIXME: source] down at the bottom, dated 01/03/2018, signed off with one last FINDMSB(3G). Go find some bits, you got this. πŸ“πŸ’…

πŸ“¦ where this page comes from