extractUint32Bits function

int extractUint32Bits(
  1. int uint32,
  2. int shift,
  3. int mask
)

Returns specific bits in a 32-bit unsigned integer.

Bits are specified by:

  • shift - Bitmask left-shift (0,1, ..., 30, 31)
  • bitmask - For example, 0xF for 4 bits.

Example: viewUint32(0xF0A0, 8, 0xF) // --> 0xA

Implementation

int extractUint32Bits(int uint32, int shift, int mask) {
  return mask & (uint32 >> shift);
}