I understand bit(n) returns the value of the bit at position n but don't understand what variable it is looking at for extracting the bit????

There is no variable. All it is doing is raising the n to the power of two. It is telling you what that bit value would be in ANY variable.

It does not look at a variable, rather it stands alone and always returns fixed values for a given value of n

From the reference page

Computes the value of the specified bit (bit 0 is 1, bit 1 is 2, bit 2 is 4, etc.

Delta_G:

All it is doing is raising the n to the power of two.

two to the power of n?

gfvalvo:

two to the power of n?

Yeah, that's what I meant. Need caffeine.

Suppose you needed to know if int variable “num” was positive or negative:

```
bool sign = num & 32768;
```

or

```
bool sign = num & 1 << 15;
```

or,

```
bool sign = num & bit(15);
```

If “sign” is true (1) num is a negative number.