~
This page is part of MariaDB's Documentation.
The parent of this page is: SQL Operators for MariaDB Xpand
Topics on this page:
Overview
Bitwise negation.
USAGE
~value
Value Name | Description |
---|---|
| The value to bitwise negate |
DETAILS
The ~
operator returns the negated value where each input bit is changed to its opposite digit.
A NULL
is returned if the value is NULL
.
The expression ~x
behaves in exactly the same manner as the function call NOTBITS(x)
.
EXAMPLES
SELECT HEX(~7), HEX(~32767), HEX(~0);
+------------------+------------------+------------------+
| HEX(~7) | HEX(~32767) | HEX(~0) |
+------------------+------------------+------------------+
| FFFFFFFFFFFFFFF8 | FFFFFFFFFFFF8000 | FFFFFFFFFFFFFFFF |
+------------------+------------------+------------------+