C# Programming - Operators - Discussion

Discussion Forum : Operators - General Questions (Q.No. 19)
19.
Which of the following statements is correct about Bitwise ^ operator used in C#.NET?
The ^ operator can be used to put ON a bit.
The ^ operator can be used to put OFF a bit.
The ^ operator can be used to Invert a bit.
The ^ operator can be used to check whether a bit is ON.
The ^ operator can be used to check whether a bit is OFF.
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
4 comments Page 1 of 1.

Caroline said:   1 decade ago
You will have to:

XOR 1 with 1 to invert it to 0 i.e. 1^1 = 0.

XOR 0 with 1 to invert it to 1 i.e. 0^1 = 1.

Ddd said:   1 decade ago
@Salvi.

It's like this 0^0 = 0, 1^1 = 0.
1^0 = 1, 0^1 = 1.

Salvi said:   1 decade ago
0^0 = 1.
1^0 = 0.

If both are same then only true.

i.e. only 0 can be used to invert.

Johan braanen said:   1 decade ago
Xor can be used to set a bit off.

Xor is used in assembly: xor eax, eax which means eax = eax^eax=0.

Post your comments here:

Your comments will be displayed after verification.