Related to CP's answer:
#define bit_set(val, bit_no) (((val) >> (bit_no)) & 1)
This numbers bits from (n-1) to 0 from the high value bits to the low, i.e. in a
short
the lowest bit (value 1) is bit number 0, and the highest (value 32768) is number 15.