Skip to main content

NOT Operator

Introduction to NOT Operator

1 min read

The Bitwise NOT operator evaluates the binary representation of the value of a single input. If the bit contains 1, the output will be 0 for that bit location. If the bit contains 0, the output will be 1.

Introduction

This lesson introduces the tilde '~' character. This is applied to a single operand and inverts each input operand's bit.

Sketch

This is the same as the NOT gate we studied in the digital electronics chapter shown below:

Logic NOT gate
Logic NOT gate

What is the Bitwise NOT operator?

The Bitwise NOT operator is denoted by ~.

The Bitwise operator evaluates the binary representation of the value of a single input. The Bitwise complement of the binary representation is determined for each bit in the binary representation. If the bit contains 1, the output will be 0 for that bit location. If the bit contains 0, the output will be 1.

Syntax

~a
  • 1 => yields 0
  • 0 => yields 1

Bitwise ~ Table

a~a
10
01

Truth table

a~a
TrueFalse
FalseTrue

Let’s see some of the Bitwise NOT operator examples in the next lesson.

Reading Progress