"#define BIT_IS_SET(i, bits) (1 << i & bits)"

1 << i

This means take the number 1 (the first "1"):

00000001

then "shifting" it right i bits. So if i was 4, 1<<i would be

00010000

See, the 1 is now 4 digits more to the left. This is exactly the same as saying

i * 16 // 16 is 2^4

The & is the bitwise AND. This means that it cycles through each bit in each byte, and if they are the same, it makes the corresponding resulting bit 1. Example:

01011001 &

11011101 =

01011001

Since 1<<i will be all zeros except for one digit, the answer will either have all 0's if that bit wasn't 1, or one 1 if the bit was one. Lucky for us, C interprets any value that's not 0 as "true" in an if-statement.

So, all in all, that define checks whether or not the "i"th bit of "bits" is 1.