C Programming - Bitwise Operators - Discussion


Bitwise & can be used in conjunction with ~ operator to turn off 1 or more bits in a number.

[A]. Yes
[B]. No

Answer: Option A


No answer description available for this question.

Sneha said: (May 5, 2011)  
Someone explain.

Sneha said: (May 5, 2011)  
Should we negate the number first and then and it to turn it off?

Sreedevi said: (Jul 11, 2011)  
I need a description for this question.

Preeti said: (Sep 22, 2011)  
We can turn off one or more bits in a number using bitwise & no need of ~ operator.

For example, Let a number 10011100

Now we want to turn its 4th nd 5th bit off, then we can do dis using & operator as

10011100 &

So in result 4th nd 5th bit are turned off.

Pooja said: (Oct 31, 2011)  
But we can't turnoff leftmost bit & 3rd bit from right here without using ~ operator.

Prakrati said: (May 28, 2012)  
Why just change the mask value.

Manoj said: (Jan 25, 2016)  
Can anyone just tell me about what is masking?

Pavan Sai said: (Jul 17, 2018)  
Here, the mask value is nothing but a number which is used to convert the given bits into the required way.

Let us take above example 11100111 is mask value.

Let us take another example, if we want to turn off the third bit from the rightmost of number 10011100 then;

10011100 &
Here the mask value is 11111011.

Post your comments here:

Name *:

Email   : (optional)

» Your comments will be displayed only after manual approval.