C Programming - Bitwise Operators - Discussion
Discussion Forum : Bitwise Operators - General Questions (Q.No. 2)
2.
Which bitwise operator is suitable for turning off a particular bit in a number?
Discussion:
41 comments Page 5 of 5.
Nag raj said:
3 years ago
Bit-wise AND operator is able to mask a particular bit.
Eg: Let us take 15 (decimal).
--->1111 (binary).
If we want 3rd bit only then simply mask the given number with 1000 by using bit-wise AND.
1111 (given number).
1000 (3rd-bit mask value).
---- - (bit-wise AND operation).
1000 (required result).
Eg: Let us take 15 (decimal).
--->1111 (binary).
If we want 3rd bit only then simply mask the given number with 1000 by using bit-wise AND.
1111 (given number).
1000 (3rd-bit mask value).
---- - (bit-wise AND operation).
1000 (required result).
(8)
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers