+ 2

What is l operator used for?

25th Sep 2016, 2:09 PM
Namra Usman
Namra Usman - avatar
2 Answers
+ 4
| is the bitwise OR. Example: #include <iostream> #include <bitset> using namespace std; int main() { cout << bitset<8>(0b10101010|0b00001111); //output: 10101111 return 0; } Other bitwise operators: & (AND), ^ (XOR), ~ (NOT), << (shift left), >> (shift right).
25th Sep 2016, 2:29 PM
Zen
Zen - avatar
+ 3
This is not covered in this course. Bitwise or is like the || logical or you learned here, but it is used on binary numbers, that consist of only 0 and 1 : 0 | 0 = 0 0 | 1 = 1 1 | 0 = 1 1 | 1 = 1 If we use this operator on two binary numbers, the first position of the first number is or'ed with the first position of the second number, the second with the second and so forth ex 0011 | 0101 = 0011 | 0101 ------ 0111
25th Sep 2016, 4:18 PM
Andres Mar