Skip to content

Latest commit

 

History

History
265 lines (161 loc) · 5.69 KB

oos_util_bit.md

File metadata and controls

265 lines (161 loc) · 5.69 KB

OOS_UTIL_BIT

BITAND Function

bitwise AND

The function signature is similar to bitand

The arguments must be in the range -(2^(32-1)) .. ((2^(32-1))-1). If an
argument is out of this range, the result is undefined.

Syntax

function bitand(
  p_x in binary_integer,
  p_y in binary_integer)
  return binary_integer
  deterministic

Parameters

Name Description
p_x binary_integer
p_y binary_integer
return binary_integer

Example


select oos_util_bit.bitand(1,3)
from dual;

OOS_UTIL_BIT.BITAND(1,3)
------------------------
                      1

BITOR Function

bitwise OR

Copied from http://www.orafaq.com/wiki/Bit

The function signature is similar to bitand

The arguments must be in the range -(2^(32-1)) .. ((2^(32-1))-1). If an
argument is out of this range, the result is undefined.

Syntax

function bitor(
  p_x in binary_integer,
  p_y in binary_integer)
  return binary_integer
  deterministic

Parameters

Name Description
p_x binary_integer
p_y binary_integer
return binary_integer

Example


select oos_util_bit.bitor(1,3)
from dual;

OOS_UTIL_BIT.BITOR(1,3)
-----------------------
                      3

BITXOR Function

bitwise XOR

Copied from http://www.orafaq.com/wiki/Bit

The function signature is similar to bitand

The arguments must be in the range -(2^(32-1)) .. ((2^(32-1))-1). If an
argument is out of this range, the result is undefined.

Syntax

function bitxor(
  p_x in binary_integer,
  p_y in binary_integer)
  return binary_integer
  deterministic

Parameters

Name Description
p_x binary_integer
p_y binary_integer
return binary_integer

Example


select oos_util_bit.bitxor(1,3)
from dual;

OOS_UTIL_BIT.BITXOR(1,3)
------------------------
                       2

BITNOT Function

bitwise NOT

Copied from http://www.orafaq.com/wiki/Bit

The function signature is similar to bitand

The arguments must be in the range -(2^(32-1)) .. ((2^(32-1))-1). If an
argument is out of this range, the result is undefined.

Syntax

function bitnot(
  p_x in binary_integer)
  return binary_integer
  deterministic

Parameters

Name Description
p_x binary_integer
return binary_integer

Example


select oos_util_bit.bitnot(7)
from dual;

OOS_UTIL_BIT.BITNOT(7)
----------------------
                    -8

BITSHIFT_LEFT Function

From https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators#Left_shift: This operator shifts the first operand the specified number of bits to the left. Excess bits shifted off to the left are discarded. Zero bits are shifted in from the right.

Syntax

function bitshift_left(
  p_x binary_integer,
  p_y binary_integer)
  return binary_integer
  deterministic

Parameters

Name Description
p_x binary_integer
p_y binary_integer
return binary_integer

Example


select oos_util_bit.bitshift_left(7, 4)
from dual;

OOS_UTIL_BIT.BITSHIFT_LEFT(7,4)
112

-- In binary terms this converted 111 (7) to 1110000 (112)

BITSHIFT_RIGHT Function

From https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators#Right_shift: This operator shifts the first operand the specified number of bits to the right. Excess bits shifted off to the right are discarded. Copies of the leftmost bit are shifted in from the left. Since the new leftmost bit has the same value as the previous leftmost bit, the sign bit (the leftmost bit) does not change. Hence the name "sign-propagating".

Syntax

function bitshift_right(
  p_x binary_integer,
  p_y binary_integer)
  return binary_integer
  deterministic

Parameters

Name Description
p_x binary_integer
p_y binary_integer
return binary_integer

Example


select oos_util_bit.bitshift_right(7, 1)
from dual;

OOS_UTIL_BIT.BITSHIFT_RIGHT(7,1)
3

-- In binary terms this converted 111 (7) to 011 (3)