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?
&& operator
& operator
|| operator
! operator
Answer: Option
Explanation:
No answer description is available. Let's discuss.
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).
(8)


Post your comments here:

Your comments will be displayed after verification.