Re: UTL_RAW binary encoding - 2

From: ddf <oratune_at_msn.com>
Date: Tue, 16 Jul 2013 06:54:23 -0700 (PDT)
Message-ID: <2e4a8ecd-eeb6-44fa-9aeb-2dd8da4b75d6_at_googlegroups.com>



On Monday, July 15, 2013 1:22:26 PM UTC-6, 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
Why? There's utl_raw.cast_from_number:

SQL> select utl_raw.cast_from_number(2147483647) from dual;

UTL_RAW.CAST_FROM_NUMBER(2147483647)



C51630312530

SQL>
SQL> select utl_raw.cast_from_number(2147483648) from dual;

UTL_RAW.CAST_FROM_NUMBER(2147483648)



C51630312531

SQL>
SQL> select utl_raw.cast_from_number(-1) from dual;

UTL_RAW.CAST_FROM_NUMBER(-1)



3E6466

SQL> David Fitzjarrell Received on Tue Jul 16 2013 - 15:54:23 CEST

Original text of this message