#Python "What is this '|'?" | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
12th Nov 2018, 5:18 PM
Fatih Yalçın
Fatih Yalçın - avatar
3 Answers
+ 4
bitwise or, google it😀
12th Nov 2018, 6:26 PM
Flandre Scarlet
Flandre Scarlet - avatar
+ 3
Bitwise OR: Compares each pair of corresponding bits from two bit patterns of equal lenght. The result in each position is 0 if both bits are 0, otherwise is 1. For example: (7|5) 0111 (Decimal 7) OR 0101 (Decimal 5) = 0111 (Decimal 7) (3|6) 0011 (Decimal 3) OR 0110 (Decimal 6) = 0111 (Decimal 7)
12th Nov 2018, 6:52 PM
Diego
Diego - avatar
+ 1
It is bitwise OR, which perform operation on bits of numbers. Its functioning can be understood from its truth table that seems to be like this: x. y. x|y 0. 0. 0 0. 1. 1 1. 0. 1 1. 1. 1 when u say 1|5 1 is written as 00001 and 5 as 00101. so when we apply or operation starting from left we have 1 and 1 so returns 1 then 0 and 0 returns 0 0 and 1 returns 1 and so for every 0 to 0 therefore the end result was like 00101 which is 5 😀
13th Nov 2018, 8:42 AM
Suzan
Suzan - avatar