Bitwise Operators
Bitwise operators supported by M-compatible databases include bitwise AND (&), bitwise OR (|), bitwise XOR (^), left shift (<<), right shift (>>), and bitwise exclusive (~). For details, see Table 1.
Priority: bitwise exclusive > bitwise XOR > left shift = right shift > bitwise AND > bitwise OR.
&
Description: Performs the bitwise AND operation.
Examples:
m_db=# SELECT 1 & 1; ?column? ---------- 1 (1 row)
|
Description: Performs the bitwise OR operation.
Examples:
m_db=# SELECT 1 | 1; ?column? ---------- 1 (1 row)
^
Description: Performs the bitwise XOR operation.
Examples:
m_db=# SELECT -1 ^ -1; ?column? ---------- 0 (1 row)
<<
Description: Performs the left shift operation.
Examples:
m_db=# SELECT 1 << 1; ?column? ---------- 2 (1 row)
>>
Description: Performs the right shift operation.
Examples:
m_db=# SELECT -1 >> -1; ?column? ---------- 0 (1 row)
~
Description: Performs the bitwise NOT operation.
Examples:
m_db=# SELECT ~1;
?column?
----------------------
18446744073709551614
(1 row)
Specification Constraints of Bitwise Operators
Bitwise operators support all data types supported by the current M-compatible database. If none of the operands is NULL, the type of the final operation result is BIGINT UNSIGNED. If any operand is NULL, the operation result is NULL.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot