Important  This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer 
C Bitwise Operators
The bitwise operators perform bitwiseAND (&), bitwiseexclusiveOR (^), and bitwiseinclusiveOR () operations.
Syntax
 ANDexpression:

equalityexpression
ANDexpression & equalityexpression
 exclusiveORexpression:

ANDexpression
exclusiveORexpression ^ ANDexpression
 inclusiveORexpression:

exclusiveORexpression
inclusiveORexpression  exclusiveORexpression
The operands of bitwise operators must have integral types, but their types can be different. These operators perform the usual arithmetic conversions; the type of the result is the type of the operands after conversion.
The C bitwise operators are described below:
Operator  Description 

&  The bitwiseAND operator compares each bit of its first operand to the corresponding bit of its second operand. If both bits are 1, the corresponding result bit is set to 1. Otherwise, the corresponding result bit is set to 0. 
^  The bitwiseexclusiveOR operator compares each bit of its first operand to the corresponding bit of its second operand. If one bit is 0 and the other bit is 1, the corresponding result bit is set to 1. Otherwise, the corresponding result bit is set to 0. 
  The bitwiseinclusiveOR operator compares each bit of its first operand to the corresponding bit of its second operand. If either bit is 1, the corresponding result bit is set to 1. Otherwise, the corresponding result bit is set to 0. 
These declarations are used for the following three examples:
short i = 0xAB00; short j = 0xABCD; short n; n = i & j;
The result assigned to n in this first example is the same as i (0xAB00 hexadecimal).
n = i  j; n = i ^ j;
The bitwiseinclusive OR in the second example results in the value 0xABCD (hexadecimal), while the bitwiseexclusive OR in the third example produces 0xCD (hexadecimal).
Microsoft Specific
The results of bitwise operation on signed integers is implementationdefined according to the ANSI C standard. For the Microsoft C compiler, bitwise operations on signed integers work the same as bitwise operations on unsigned integers. For example, 16 & 99 can be expressed in binary as
11111111 11110000 & 00000000 01100011 _________________ 00000000 01100000
The result of the bitwise AND is 96 decimal.
END Microsoft Specific