BITFIELDEXTRACT(3G)

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

πŸŽ€ BITFIELDEXTRACT(3G) πŸŽ€

okay bestie, you've landed on BITFIELDEXTRACT(3G) πŸ’– this whole page is about one lil function called bitfieldExtract, and her entire personality is "gimme an integer, I'll hand you back a slice of its bits." no cap. let's get into it πŸ¦‹


✨ NAME ✨

bitfieldExtract β€” extract a range of bits from an integer πŸ“


πŸ’… DECLARATION πŸ’…

genIType bitfieldExtract(genIType value, int offset, int bits);

genUType bitfieldExtract(genUType value, int offset, int bits);

two flavours, same energy. pick the one that matches your type, she's not picky πŸ‘‘


🌸 PARAMETERS 🌸

  • value β€” the integer you're pulling bits out of. your source material, your main character πŸ’œ
  • offset β€” the index of the first bit to extract. where the slice starts, fr fr.
  • bits β€” how many bits you want. the size of your little scoop 🍨

πŸ”₯ DESCRIPTION πŸ”₯

okay so bitfieldExtract takes a subset of the bits of value and returns them in the least significant bits of the result. it's giving "cut a strip out and slide it down to the front."

the range of bits extracted is [offset, offset + bits + 1].

for unsigned data types, the most significant bits of the result will be set to zero. clean. pristine. zeroes. ✨

for signed data types, the most significant bits will be set to the value of bit offset + base - 1 (i.e., it is sign extended to the width of the return type). so she copies the sign bit all the way up, iconic behaviour.

if bits is zero, the result will be zero. periodt. nothing in, nothing out πŸ«₯

🚨 the result will be undefined if offset or bits is negative, or if the sum of offset and bits is greater than the number of bits used to store the operand. bestie. do NOT do this. that's not a vibe check, that's a vibe crash. πŸ’€

🌈 VERSION SUPPORT 🌈

so here's the tea on which OpenGL Shading Language versions ship her. the row is labelled bitfieldInsert in the original (yes, we're all just gonna look at that and move on πŸ™ˆ), and the columns run 1.10, 1.20, 1.30, 1.40, 1.50, 3.30, 4.00, 4.10, 4.20, 4.30, 4.40, 4.50:

  • 1.10 β€” - (not here, girl)
  • 1.20 β€” -
  • 1.30 β€” -
  • 1.40 β€” -
  • 1.50 β€” -
  • 3.30 β€” -
  • 4.00 β€” βœ”
  • 4.10 β€” βœ”
  • 4.20 β€” βœ”
  • 4.30 β€” βœ”
  • 4.40 β€” βœ”
  • 4.50 β€” βœ”

so she showed up in 4.00 and never left. consistent queen πŸ‘‘


πŸ‘€ SEE ALSO πŸ‘€

bitfieldExtract()

(yeah. she's linking herself. self-love is the moment. slay πŸ’…)


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 bestie 🫢 source says [FIXME: source], the date on this one is 01/03/2018, and it's filed under BITFIELDEXTRACT(3G). go extract some bits, you absolute legend πŸŒŸπŸ’–

πŸ“¦ where this page comes from