Switch to: V9V8V7V6V5

Bitwise Functions

Valentina has set of functions to do bit operations. On default 64-bit arithmetic is used.

BIT_AND(X, Y)

Returns the bit AND for arguments X and Y.

SELECT BIT_AND( 29, 15 );
=> 13

BIT_OR(X, Y)

Returns the bit OR for arguments X and Y.

SELECT BIT_OR( 29, 15 );
=> 31

BIT_XOR(X, Y)

Returns the bit XOR for arguments X and Y.

SELECT BIT_XOR( 1, 1 );
=> 0
 
SELECT BIT_XOR( 1, 0 );
=> 1

BIT_NOT(X)

Returns the inverted bits of argument X.

SELECT BIT_NOT( BIT_NOT(5) );
=> 5

BIT_COUNT(X)

Returns the count of bits that are set in the argument X.

SELECT BIT_COUNT( 5 );
=> 2

X << Y

Shifts bits of the argument X to the left.

SELECT 1 << 3
=> 8

X >> Y

Shifts bits of the argument X to the right.

SELECT 8 >> 3
=> 1