What is the difference between ( | )and ( || ) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

What is the difference between ( | )and ( || )

9th Jan 2017, 8:34 AM
Utkαrsh
Utkαrsh - avatar
3 Answers
+ 9
|| is a logical OR operator which returns either True or False | is a bitwise operator for example, take the numbers 2 and 5. their bit representations are: 2: 010 5: 101 the bitwise operator takes every corresponding bits of the same column and perform an OR operation. so in the example above we get: 2: 010 5: 101 x: 111 and 111 in binary is 7, thus, x is 7
9th Jan 2017, 9:07 AM
Burey
Burey - avatar
+ 3
|=Bitwise ||=OR
10th Jan 2017, 3:09 PM
Bruh
+ 2
| is bitwise or. And || is a logical or operator. | is operated on bits, it returns 1 if any of the two compared bits is 1. || is operated on conditions, it returns true if any of the condition is true.
9th Jan 2017, 9:02 AM
Divesh Agarwal
Divesh Agarwal - avatar