C# - Bitwise not: ~

Bitwise 1 complement, also known as bit negation or bit-denial operation. operates on the basis of logical negation, if input is 0 then output is 1, and if input is 1 the result is 0. for example you can use it for bit deletion, or bit set to simplify the creation of masks. for example, at one variable we want to set to 1 all bits except the first 3 bits, in which case we will use a bitwise OR, given what we need one mask in case of 16-bit variable is a number 65528, using a bitwise negation we can use a simpler form number 7. reasoning is as follows, with the exception of the first three bits we want to set bits to 1, we need a mask where the first three bits are 0 and the other 1, the opposite is the first of three bits are 1 other 0, this number is simple to calculate, and then apply a bitwise negation and we have done.

~

Description

~ par1
Used keywords: ~

Input


Output

Examples

C#

Bitwise not the possible of use:
x = ~(32 >>2);       // x = -9
y = ~x;              // y = 8
z = ~(x & 5) & y;    // z = 8

C#

Even one example in what situations we can use the operation bitwise not:
~i
~0xabcd
~(i & 4)

C#

Other pieces of example codes:
~ 2

You can find it in the following collections: bitwise operators
Languages: en hu cz sk