Convert raw or hex value to signed 2's complement via Oracle SQL Is there a way to convert either HEX or RAW value to signed 2's complement via Oracle SQL?
example:
hex: 8508 &gt; dec: 34046 &gt; dec from signed 2's complement: -31480
The number that I am trying to get within my SQL statement is -31480.
Using the expression
result = -(x &amp; mask) + (x &amp; !mask)

where mask=2^(n-1) yields the result you want.  The (x &amp; mask) isolates the sign bit and (x &amp; !mask) is the offset.  When the sign bit is not set, (x &amp; mask) == 0 and (x &amp; !mask) is the result.  When the sign bit is set, -(x &amp; mask) == -2^(n-1) and (x &amp; !mask) is the offset from the most negative number.
Next we convert the hexadecimal string to a raw representation by using HEXTORAW().  The raw representation is cast to an integer with UTL_RAW.CAST_TO_BINARY_INTEGER().
Assuming 16 bit:

select 
  x,
  -BITAND(utl_raw.cast_to_binary_integer(hextoraw(x)),32768) 
    +BITAND(utl_raw.cast_to_binary_integer(hextoraw(x)),32767)  
  from (select '8508' x from dual);

DB Fiddle example
Note:  You probably want to do the utl_raw.cast_to_binary_integer(hextoraw(...)) once instead of twice.