Re: UTL_RAW binary encoding - 2

From: <kooroorinya_at_gmail.com>
Date: Tue, 16 Jul 2013 19:54:08 -0700 (PDT)
Message-ID: <c5aeebe7-4119-4ff7-8c61-c677a9cef4c1_at_googlegroups.com>



On Tuesday, July 16, 2013 5:22:26 AM UTC+10, neilsolent wrote:
> I seek a function similar to utl_raw.cast_from_binary_integer [see examples below] BUT I need it to:
>
> 1. Work with 8-byte numbers (not limited to 4 bytes)
>
> 2. Work with unsigned integers (negative numbers do not take up 1/2 of the "range"):
>
>
>
> Does anyone know how to create such a function?
>
>
>
> Thanks,
>
> Neil
>
>
>
>
>
> SQL> select utl_raw.cast_from_binary_integer(2147483647) from dual;
>
>
>
> UTL_RAW.CAST_FROM_BINARY_INTEGER(2147483647)
>
> --------------------------------------------------------------------------------
>
> 7FFFFFFF
>
>
>
> SQL> select utl_raw.cast_from_binary_integer(2147483648) from dual;
>
>
>
> UTL_RAW.CAST_FROM_BINARY_INTEGER(2147483648)
>
> --------------------------------------------------------------------------------
>
> 7FFFFFFF
>
>
>
> SQL> select utl_raw.cast_from_binary_integer(-1) from dual;
>
>
>
> UTL_RAW.CAST_FROM_BINARY_INTEGER(-1)
>
> --------------------------------------------------------------------------------
>
> FFFFFFFF
What about using the TO_CHAR function converting to hex ?

SQL> select TO_CHAR(2147483648,'XXXXXXXX') from dual;

TO_CHAR(2



 80000000

SQL> Otherwise there are many options for base conversion functions available Received on Wed Jul 17 2013 - 04:54:08 CEST

Original text of this message