Introduction to NOT Operator
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.
Table of Contents
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:
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 |
---|---|
1 | 0 |
0 | 1 |
Truth table
a | ~a |
---|---|
True | False |
False | True |
Let’s see some of the Bitwise NOT
operator examples in the next lesson.
Gopi Gorantala Newsletter
Join the newsletter to receive the latest updates in your inbox.