Returns the inverse of the bits set in the argument.
SDK
- Xcode 9.0+
Framework
- Swift Standard Library
Declaration
Discussion
The bitwise NOT operator (~
) is a prefix operator that returns a value in which all the bits of its argument are flipped: Bits that are 1
in the argument are 0
in the result, and bits that are 0
in the argument are 1
in the result. This is equivalent to the inverse of a set. For example:
Performing a bitwise NOT operation on 0 returns a value with every bit set to 1
.
Complexity: O(1).