where n is the bit number, and 0 is the least significant bit)
Example:
Example:
Test a bit:
assuming 16 bit, 2-byte short integer:
assuming 16 bit, 2-byte short integer, two's complement:
The code below shows how to set or clear a bit of an integer.
Output is: