4 Answers
New AnswerLoma , 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
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
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
Sololearn Inc.
535 Mission Street, Suite 1591Send us a message