+ 3
Bitwise pipe operator
How does print (5|3) return 7?
4 odpowiedzi
+ 3
Loma , I'm sorry but that isn't true... Bitwise or operator performs bitwise or operation, not addition (that's why it is called bitwise or ;) )
So it is
0101
Or 0011 =
------------
0111 = 7
By the way
0101
+ 0011
-----------
1000 = 8
+ 9
5 binary representation is 0b101 and for 3 it is 0b011 and that is bitwise or operator which returns 1 if either bit is 1 else 0 ,so after calculation you get 0b111 whose representation in decimal is 7
+ 4
G B you are right👍
+ 2
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 output is 1 else 0