+ 10

how does "bitwise or (|)" operator work?

I didn't understand that, how to use "|" operator in python.

18th Jan 2022, 7:00 AM
Sujal
Sujal - avatar
3 Answers
18th Jan 2022, 7:22 AM
Simba
Simba - avatar
+ 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)
19th Jan 2022, 3:43 AM
Vaibhav
Vaibhav - avatar
18th Jan 2022, 7:21 AM
NEZ
NEZ - avatar