VOOZH about

URL: https://www.geeksforgeeks.org/javascript/not-bitwise-operator-in-javascript/

⇱ NOT(~) Bitwise Operator in JavaScript - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

NOT(~) Bitwise Operator in JavaScript

Last Updated : 23 Jul, 2025

JavaScript NOT(~) Operator is used to invert the bits of a number. The operator is represented by "~" symbol. It is a unary operator since it requires only one operand to operate. There are various uses of the Bitwise NOT operator which include bit-masking, finding two's complement as well as error correction.

Let's look at the truth table below to better understand the output of the NOR operation.

AOUTPUT ( ~A )
01
10

Syntax:

a ~ b

Example 1: In this example, we will perform basic NOT operation on Numbers.

Output:

-25
-11
9

Example 2: In this example, we will use the Bitwise NOT operator to find Two's Complement of a number.

Output: To find the two's complement we first convert the decimal number to binary then invert the bits using NOT Operator and add 1 afterward.

-10
10

Supported Browsers:

  • Chrome
  • Edge
  • Firefox
  • Opera
  • Safari

We have a complete list of JavaScript Bitwise Operators, to check those please go through, the JavaScript Bitwise Operators article

Comment
Article Tags: