A bit mask is a deliberately constructed bit pattern used with bitwise operations to inspect or modify selected positions in another pattern. With bit-and, 1s preserve corresponding bits and 0s hide them. section 3.2.3
Use the mask according to the desired bit operation:
- Flip positions with bit-xor and a mask containing 1s at those positions; compare bit sets by checking whether xor produces only 0s. section 3.2.3
Inspect and clear the fourth bit
Define the fourth-bit mask as 2r00001000. Applying (bit-and 2r11001001 fourth-bit-set-mask) yields "00001000", confirming that the position is set. Applying (bit-clear 2r11001001 3) yields "11000001", clearing that position without explicitly supplying an inverted mask.
