Search⌘ K
AI Features

Masks and Their Construction

Explore techniques for constructing bit masks in C to manipulate specific bits with AND, OR, and XOR operations. Understand how to use hexadecimal values and the BV macro for clear and efficient bit setting.

Creating mask values

Suppose n = 45 and your task is to:

  • AND it with a number whose 3rd bit is on
  • OR it with a number whose 7th bit is on
  • XOR it with a number whose 4th bit is on

The ...