Bitwise-Inclusive-OR Operator:  |

inclusive-OR-expression :

exclusive-OR-expression
inclusive-OR-expression**|** exclusive-OR-expression

The bitwise-inclusive-OR 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.

Example

In the following example, the bitwise-inclusive-OR operator (|) compares the bits of two integers, nNumA and nNumB:

// Example of the bitwise-inclusive-OR operator
int nNumA=9, nNumB=3, nNumC; // 00001001, 00000011

nNumC = nNumA | nNumB;       // nNumC is now 11: 00001011

For related information, see bitwise-AND, bitwise-exclusive-OR, shift operators, and one's complement.