Cheese icon

Bitwise Not Of A Number in Python

Author: guiferviz

Created:

Last Modified:

In Python, the ~ operator is the bitwise NOT operator. When applied to an integer x, it flips all the bits of x. For a positive integer x, this is equivalent to -(x + 1).

The reason for this is that Python, as many other computer languages, works with Two's Complement.

Use Case

Compute Median In Python With Bitwise Not.