PostgreSQL - Bitwise Operators
Here are simple examples showing the usage of PostgreSQL Bitwise Operators.
Assume variable A holds 60 and variable B holds 13 then −
testdb=# select 60 | 13;
?column?
----------
61
(1 row)
testdb=# select 60 & 13;
?column?
----------
12
(1 row)
testdb=# select (~60);
?column?
----------
-61
(1 row)
testdb=# select (60 << 2);
?column?
----------
240
(1 row)
testdb=# select (60 >> 2);
?column?
----------
15
(1 row)
testdb=# select 60 # 13;
?column?
----------
49
(1 row)
postgresql_operators.htm
Advertisements