0
I’ve read some things here at Stack Overflow, but I don’t quite understand.
What is bit-to-bit operation?
For example, in the context:
Considering bit-to-bit operation 15 3, the result will be:
0
I’ve read some things here at Stack Overflow, but I don’t quite understand.
What is bit-to-bit operation?
For example, in the context:
Considering bit-to-bit operation 15 3, the result will be:
6
The point is, what does it mean 15 ^ 3
or 15 xor 3
bit by bit?
First we convert 15 and 3 of the decimal base into binary basis:
15 : 1111
3 : 0011
How the XOR works?
Xor or OR Exclusive (or exclusive) is true if bits A B are different and false if they are equal, which gives this table
A 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 perform the bit-to-bit 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
, decimally is 12.
Now I understand! Thank you, William!
Browser other questions tagged bit
You are not signed in. Login or sign up in order to post.
Give context.
– Maniero
Edited, by Maniero!
– Lucas de Carvalho
@Lucascarvalho is an operation made with the bits of the variables, not with their integer values
– Jefferson Quesado
Related: Operator " | " in Java | What does the "|=" Python operator mean?
– Woss
Is it just the operator? Really?
– Lucas de Carvalho