# bitfieldExtract

## 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);

## Parameters

value

Specifies the integer from which to extract bits.

offset

Specifies the index of the first bit to extract.

bits

Specifies the number of bits to extract.

## Description

bitfieldExtract extracts a subset of the bits of value and returns it in the least significant bits of the result. 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. 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).

If bits is zero, the result will be zero. 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.

## Version Support

OpenGL Shading Language Version
Function Name 1.10 1.20 1.30 1.40 1.50 3.30 4.00 4.10 4.20 4.30 4.40 4.50
bitfieldInsert - - - - - -

## See Also

Think you can improve this page? Edit this page on GitHub.