How does bitwise and work in Arduino?
What is the bitwise OR operator in C++?
- The bitwise OR operator in C++ is the vertical bar symbol, |. Like the & operator, | operates independently each bit in its two surrounding integer expressions, but what it does is different (of course). The bitwise OR of two bits is 1 if either or both of the input bits is 1, otherwise it is 0.
What is the bitwise XOR operator?
- (In English this is usually pronounced "eks-or".) The bitwise XOR operator is written using the caret symbol ^. This operator is very similar to the bitwise OR operator |, only it evaluates to 0 for a given bit position when both of the input bits for that position are 1:
What is the bitwise OR of two bits?
- The bitwise OR of two bits is 1 if either or both of the input bits is 1, otherwise it is 0. int a = 92; // in binary: 0000000001011100 int b = 101; // in binary: 0000000001100101 int c = a | b; // result: 0000000001111101, or 125 in decimal. One of the most common uses of the Bitwise OR is to set multiple bits in a bit-packed number.
Share this Post: