+ 10
how does "bitwise or (|)" operator work?
I didn't understand that, how to use "|" operator in python.
3 Answers
+ 12
Bitwise or operator:
Returns 1 if either of the bit is 1 else 0.
Example:
a = 10 = 1010 (Binary)
b = 4 = 0100 (Binary)
a | b = 1010
|
0100
= 1110
= 14 (Decimal)
+ 5
Then have a look to these links:
https://stackoverflow.com/questions/1746613/bitwise-operation-and-usage