Bitwise Operator

A Bitwise operator performs operations in bits, and can be used in arithmetic operations. An integer type is specified as the operand and the BIT type cannot be specified. An integer of BIGINT type (64-bit integer) is returned as the result of the operation. If one or more operand is NULL, NULL is returned.

The following table shows the bitwise operators supported by CUBRID.

The bitwise operators supported by CUBRID

Bitwise operator

Description

Expression

Return Value

&

Performs AND operation in bits and returns a BIGINT integer.

17 & 3

1

|

Performs OR operation in bits and returns a BIGINT integer.

17 | 3

19

^

Performs XOR operation in bits and returns a BIGINT integer.

17 ^ 3

18

~

A unary operator. It performs complementary operation that reverses (INVERT) the bit order of the operand and returns a BIGINT integer.

~17

-18

<<

Performs the operation of moving bits of the left operand as far to the left as the value of the right operand, and returns a BIGINT integer.

17 << 3

136

>>

Performs the operation of moving bits of the left operand as far to the right as the value of the right operand, and returns a BIGINT integer.

17 >> 3

2