Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Re: % Negation Character

Re: % Negation Character

From: Nigel Thomas <nigel_cl_thomas_at_yahoo.com>
Date: Mon, 18 Jun 2007 08:40:58 -0700 (PDT)
Message-ID: <330952.80480.qm@web58712.mail.re1.yahoo.com>


Citali wrote:



raw_value := utl_raw.cast_from_number('2'); -- This is equal to c103           

select utl_raw.bit_COMPLEMENT('c103') from dual;

 UTL_RAW.BIT_COMPLEMENT('C103')



 3efc           

SELECT utl_raw.cast_to_number('3efc') FROM dual

UTL_RAW.CAST_TO_NUMBER('3EFC')



 -105

What I'm expecting is: 13 ...



Citali

cast_to_raw takes an Oracle number and shows you its hex representation. That's not the same as converting a binary number into hex. Use the CAST_FROM_BINARY_INTEGER (if you supply a 'normal' number or literal, there will be an implicit conversion of the parameter):

SQL*Plus: Release 10.2.0.1.0 - Production on Mon Jun 18 16:30:02 2007 Copyright (c) 1982, 2005, Oracle. All rights reserved. SQL> connect testuser/testuser
Connected.
SQL> select utl_raw.cast_from_binary_integer(256) from dual   2 /
UTL_RAW.CAST_FROM_BINARY_INTEGER(256)



00000100
SQL> Now you should be able to do your logic using other UTL_RAW functions.... Keep an eye on the length of the RAWs....

Regards Nigel

--
http://www.freelists.org/webpage/oracle-l
Received on Mon Jun 18 2007 - 10:40:58 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US