I have read some things here in Stack Overflow, but I did not quite understand it.
What is bit-to-bit operation?
For example, in the context:
Given the bit-to-bit operation 15 ^ 3, the result will be:
I have read some things here in Stack Overflow, but I did not quite understand it.
What is bit-to-bit operation?
For example, in the context:
Given the bit-to-bit operation 15 ^ 3, the result will be:
The question is: What does 15 ^ 3
or 15 xor 3
bit by bit mean?
First convert 15 and 3 decimal base into binary base:
15 : 1111
3 : 0011
How does XOR work?
Xor or OR Exclusive (or exclusive) is true if bits A B are different and false if they are equal, which gives this tableA B XOR
0 0 | 0
0 1 | 1
1 0 | 1
1 1 | 0
Now you have to pair the 3 and 15 binary vertically and carry out the bitwise XOR operation
Bit A B XOR
1 1 1 | 0
2 1 1 | 0
3 1 0 | 1
4 1 0 | 1
That is, the result of 0b1111 xor 0b0011
is 0b1100
, in decimal it is 12.