# Bitwise not: ~, 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: ~

### Output

Compatible programing languages:
C | Visual C++ .NET | C++ | C# | Java | JavaScript | PHP

### Example

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

### Example

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

### Example

Other pieces of example codes:
`~ 2`

## not

### Description

``not par1``
Used keywords: not

### Output

Compatible programing languages:
Basic | Visual Basic .NET | FreeBASIC | Free Pascal | Object Pascal | Pascal

### Basic

Even one example in what situations we can use the operation bitwise not:
``````not i
not&Habcd
not(i and 4)``````

### Basic

Other pieces of example codes:
`not a`
`not 2`

You can find it in the following collections: bitwise operators
Bitwise not in another programming language:
Languages: en hu cz sk