https://codeeval.dev/gist/934fcd2806c5a568e9fa59fc9870e9f4
Why
A bit wise OR
operates on the bit level and uses the following Boolean truth table:
true OR true = true
true OR false = true
false OR false = false
When the binary value for a
(0101
) and the binary value for b
(1100
) are OR
’ed together we get the binary value of 1101
:
int a = 0 1 0 1
int b = 1 1 0 0 |
---------
int c = 1 1 0 1
The bit wise OR does not change the value of the original values unless specifically assigned to using the bit wise assignment compound operator |=
: