transformUint32Bool function

int transformUint32Bool(
  1. int uint32,
  2. int shift,
  3. bool newValue
)

Replaces a single bit in a 32-bit unsigned integer.

Implementation

int transformUint32Bool(int uint32, int shift, bool newValue) {
  return ((0xFFFFFFFF ^ (0x1 << shift)) & uint32) |
      ((newValue ? 1 : 0) << shift);
}