Sorry about that, the forum apparently doesn’t like less than signs. Those were supposed to be bit-shifts.

If we say a shift left (i.e. double chevron less-than) is SHIFT_L, and a shift right is SHIFT_R

then it’d be

(i & (1 SHIFT_L n)) SHIFT_R n

so the SHIFT_L by n will create your mask by shifting the 1 to the nth bit, then when you take the bit-wise and of it and i, you get the ith bit. The SHIFT_R by n will shift that bit back to its original position.

For example:

```
void print_binary(int num)
{
printf("%d in binary:\n");
for (int i = 0; i < 32; i++)
{
int bit_val = (num & (1 SHIFT_L i)) SHIFT_R i;
printf(" %d ", bit_val);
}
printf("\n");
}
```

Sorry for the cryptic syntax, but hopefully you get the idea