answersLogoWhite

0

The bitwise complement or one's complement operator (~) is used to switch the state of all the bits in a value. Thus 1's become 0, and 0's become 1.

One of its many uses is to unset individual bit(s) in a bitmap. We do this with a bitwise AND of the bitmap and the bitwise complement of the bit(s) we want to unset.

Original bitmap: 01011100

Bit to unset: 00000100 (e.g., bit 2 (bits are zero based from right))

// Using one's complement and bitwise AND

~00000100 & 01011100

11111011 (one's complement of bit 2)

&

01011100 (original bitmap)

=

01011000 (original bitmap with bit 2 unset)

Note that this formula works even if bit 2 were already unset:

11111011 (one's complement of bit 2)

&

01011000 (original bitmap, with bit 2 unset)

=

01011000 (original bitmap unchanged)

User Avatar

Wiki User

13y ago

What else can I help you with?

Related Questions

Use of scope resolution operator in C programming?

:: operator can not be used in C.


What is the memory management operator in c plus plus?

There is no memory management operator in C++ -- it is an unmanaged language. You use the C++ new operator to allocate memory, and use the C++ delete operator to release previously allocated memory.


When do we use an address operator in c'?

In C we use & operator while giving address of some variable to some pointer variable. & operator is also used in scanf().


What is the operator of power in c plus plus?

There is no "power" operator in C or C++. You need to the use the math library function pow().


Why are there 2 plus sign in c plus plus and Why not a single plus sign?

In C and in C++, the ++ operator means to increment. C++ was intended to be the next version, i.e. the incremental next step, of C, hence the use of the ++ operator.


Why should you have to use comparison operator overloading in pairs in c?

You cannot overload operators in C. This is a C++ thing only.


What are the basic operator in turbo c?

+ += - -= * *= / /= % %= = == != <= >= & && | ^ ~ << <<= >> >>= , [] () are the basic operator in TURBO C


What is the operator that cannot be overloaded in c plus plus and java?

conditional operator , size of operator , membership operator and scope resulation operator can not be overload in c++


What are the advantage and disadvantage of operator overloadin?

Operator overloading allows c/c++ operators to have user defined meanings on user defined types. For example + operator is used to add to numbers but we can also use it for concatenating a string the only limitation is you cannot change the literal meaning of the operator.


Which operator will let us use multiple statement in an expression in c?

The comma operator will let you use multiple statements in an expression in C or C++.Strictly speaking, you cannot have a statement inside an expression, for example the following is completely wrong:int n;n = 1 + for (i=0; i


Is it possible to do operator overloading in c?

No. Operator and/or function overloading is only a C++ thing.


What is the meaning of and in C programming language and when is it used?

logical and: exp1 && exp2 means: exp1==0 ? 0 : exp2==0 ? 0 : 1