https://codeeval.dev/gist/a7836d2231586fe31aecc65ed7964a70
Why
A bit wise AND
operates on the bit level and uses the following Boolean truth table:
TRUE AND TRUE = TRUE
TRUE AND FALSE = FALSE
FALSE AND FALSE = FALSE
When the binary value for a
(0110
) and the binary value for b
(1010
) are AND
’ed together we get the binary value of 0010
:
int a = 0 1 1 0
int b = 1 0 1 0 &
---------
int c = 0 0 1 0
The bit wise AND does not change the value of the original values unless specifically assigned to using the bit wise assignment compound operator &=
: