complement

How does Python's bitwise complement operator (~ tilde) work?

How does Python's bitwise complement operator (~ tilde) work? Question: Why is it that ~2 is equal to -3? How does ~ operator work? Asked By: bala || Source Answers: ~ flips the bits in the value. Why ~2 is -3 has to do with how numbers are represented bitwise. Numbers are represented as two’s …

Total answers: 18