1

I am trying to figure out all of the common bit-wise operations in Oracle.

In SQL Server we have some very simple bit-wise operators to use against a bit-wise value:

  • & - Evaluates if bit exists select 10 & 2 /* result=2 */
  • | - Add Bit (if doesn't exist) select 10 | 2 /* result=10 */
  • &~ - Remove Bit (if exists) select 10 &~ 2 /* result=8 */
  • ^ - Toggle Bit (remove if exists, adds if doesn't) select 10 ^ 2 /* result = 8 */

In Oracle, I know we have a built-in bitand() function which is more or less equivalent to SQL Server &, and I have built an Oracle bit-wise OR function to mimic SQL server's bit-wise OR operation (|) as follows:

CREATE OR REPLACE FUNCTION BITOR (x IN NUMBER, y IN NUMBER) RETURN NUMBER AS
    BEGIN
       RETURN x + y - BITAND(x,y);
    END;

My question is: how can I achieve the SQL Server &~ and the ^ operations in Oracle?

GWR
  • 2,847
  • 9
  • 35
  • 42

1 Answers1

-1

Have you checked the manual?, it should help with your question to a large extent.

Raj
  • 912
  • 4
  • 5