0
What is Bitwise and what is the difference between Bitwise Exclusive Or and Regular Or?
2 ответов
+ 2
Bitwise: Regular True/False comparison is not being done (otherwise values like 3 would always be true). Instead, for (numeric) values each binary digit (bit) of the binary expansion is compared, one at a time.
OR: if either bit compared is 1, return 1 for that bit position.
XOR: Either one OR the other bit can be 1, but not both (one excludes the other):
first second |or ^xor
0 0 0 0
0 1 1 1
1 0 1 1
1 1 1 0 <-difference
5 | 3 = 7 (101 or 011 = 111)
5 ^ 3 = 6 (101 xor 011 = 110)
0
as name suggests bitwise or implement on bits by changing into its binary form and simple or is used to check that if any condition is true in given two conditions