C# Programming - Operators - Discussion
Discussion Forum : Operators - General Questions (Q.No. 8)
8.
Which of the following statements are correct about the Bitwise & operator used in C#.NET?
- The & operator can be used to Invert a bit.
- 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 check whether a bit is ON.
- The & operator can be used to check whether a bit is OFF.
Discussion:
9 comments Page 1 of 1.
Jay said:
1 decade ago
1st option is WRONG because & operator never works on single bit ,it require minimum 2 bit like ( 1 & 1 = 1 or 1 & 0 = 0), so no hope for 1.
2nd option is WRONG because 1 & 1 = 1 i.e ON. when bits are already ON then it makes no sense.
3rd is CORRECT because 1 & 0 = 0 i.e OFF. it makes sense here. Any one of the bit is OFF then Then results comes OFF.
4th is also CORRECT. when u have a bit ,try to AND it with 1 and if you get result 1 i.e ON then Prev bit was 1 i.e 1
and if you get result 0 (OFF) then but obvious Prev bit was 0 that's why option 5 is also CORRECT
2nd option is WRONG because 1 & 1 = 1 i.e ON. when bits are already ON then it makes no sense.
3rd is CORRECT because 1 & 0 = 0 i.e OFF. it makes sense here. Any one of the bit is OFF then Then results comes OFF.
4th is also CORRECT. when u have a bit ,try to AND it with 1 and if you get result 1 i.e ON then Prev bit was 1 i.e 1
and if you get result 0 (OFF) then but obvious Prev bit was 0 that's why option 5 is also CORRECT
Sumit Sharma said:
1 decade ago
3. If bit is ON means bit=1 by ending this bit with 0 we can OFF this bit i.e 1&0=0.
4 and 5. We can check a bit is ON by ending bit with 1 i.e
If bit&1=1 (bit is ON) else bit is OFF.
So Points 3,4 and 5 are correct.
4 and 5. We can check a bit is ON by ending bit with 1 i.e
If bit&1=1 (bit is ON) else bit is OFF.
So Points 3,4 and 5 are correct.
Manisha said:
1 decade ago
It means that and is use for the multiplication purpose.
1 1 = 1 means on to checks.
1 0 = 0 off.
0 1 = 0 off.
0 1 = 0 off.
1 1 = 1 means on to checks.
1 0 = 0 off.
0 1 = 0 off.
0 1 = 0 off.
Rekha said:
1 decade ago
Am not getting this can you please explain me clearly.
Amala said:
1 decade ago
Please any one eplain, I am not getting answer.
Bhairav said:
1 decade ago
I am not getting this point please explain ?
Tej Pratap said:
1 decade ago
Please explain this question.
Deepika said:
1 decade ago
Please anyone explain?
Harisan said:
1 decade ago
Explain it.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers