The bitwise OR (|) operator performs an OR operation on each bit of a binary number: if a certain bit of both is 1, the bit in the result is 1; if a certain bit of the two If one bit is 0, then the bit in the result is 0. It is used to: extract bits set bits clear bits test bits
in C | Meaning of
in C , the |
symbol represents the "bitwise OR" operator, which performs an OR operation on each bit of two binary numbers.
How to perform a bitwise OR operation
When two binary numbers are operated using the bitwise OR operator, each of their bits is compared individually:
Example
Consider the following two binary numbers:
A = 01001101
B = 10011011
Perform a bitwise OR operation on them:
<code>A | B = 01001101 | 10011011 ------- = 11011111</code>
The result is 11011111
.
Use of bitwise OR operation
Bitwise OR operation is very useful in the following situations:
The above is the detailed content of What does | mean in c++. For more information, please follow other related articles on the PHP Chinese website!