---
title: 3.18 Bitwise NOT
description: "The bitwise NOT operator `~` inverts every bit of an integer operand. Each `0` bit becomes `1`, and each `1` bit becomes `0`. ``` #include int main() { unsigned char number = 12; printf(\"number = %un\", number); printf(\"~number = %un\",…"
url: "https://edcret.in/docs/c-programming/operators-and-expressions/3-18-bitwise-not/"
updated: "2026-09-07"
category: C Programming / Operators and Expressions
---

# 3.18 Bitwise NOT

The bitwise NOT operator `~` inverts every bit of an integer operand. Each `0` bit becomes `1`, and each `1` bit becomes `0`.

```
#include <stdio.h>

int main()
{
    unsigned char number = 12;

    printf("number = %un", number);
    printf("~number = %un", (unsigned char)~number);

    return 0;
}
```

### Example Output

```
number = 12
~number = 243
```

### Explanation

The value `12` is represented using 8 bits as:

```
12 = 00001100
```

Applying the bitwise NOT operator inverts every bit:

```
    00001100~    00001100     --------     11110011
```

`11110011` is `243` in decimal.

The cast:

```
(unsigned char)~number
```

keeps the result to the 8-bit `unsigned char` representation used by the example. Without the cast, the operand undergoes integer promotion before the `~` operation, so the result would be affected by the wider integer type.

Unlike logical NOT `!`, which produces only `0` or `1`, bitwise NOT `~` operates on every bit of the integer operand.
