Oracle bitwise exception in Oracle

In SQL Server, I used the ^ character, however this does not work in Oracle .

How to make bitwise exclusive OR in Oracle?

+7
database bit-manipulation oracle stored-procedures
source share
4 answers

From the docs:

 function bitor(p1 number, p2 number) return number is begin return p1-bitand(p1,p2)+p2; end; function bitxor(p1 number, p2 number) return number is begin return bitor(p1,p2)-bitand(p1,p2); end; 

To see what these works, follow the logic with 0s and 1s for input, and then no, that there are no borrowings or caries.

- MarkusQ

+7
source share

There is a BITAND statement:

 select bitand(49,54)+0 from dual; 

You can create other operators from it ; and here .

+5
source share

There is no easy way.

You can specify HEX string values ​​in RAW values ​​and use UTL_RAW :

 SELECT UTL_RAW.bit_xor(HEXTORAW(TO_CHAR(1, 'FMX')), HEXTORAW(TO_CHAR(2, 'FMX'))) FROM dual --- 03 
+2
source share
+1
source share

All Articles