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

Home -> Community -> Usenet -> c.d.o.misc -> Re: Bit-Manipulation???

Re: Bit-Manipulation???

From: P Jeromel <pjeromel_at_hotmail.com>
Date: Mon, 21 Jun 1999 11:22:21 +0930
Message-ID: <376D9AD5.9861351D@hotmail.com>


Thomas,

Sorry, my mistake.

Thanks.
Paul

Thomas Kyte wrote:

> A copy of this was sent to P Jeromel <pjeromel_at_hotmail.com>
> (if that email address didn't require changing)
> On Mon, 21 Jun 1999 09:42:46 +0930, you wrote:
>
> >Thomas,
> >
> >Thanks for the function, although, which package does the bitand() come from?
> >(Or what permissions do I need, I can't seem to execute it).
> >
>
> what is the error? bitand() is available everywhere -- its used in the data
> dictionary, in plsql, all over. Its an internal function like substr. can you
> send me a cut and paste of your attempt to use it and the resulting error?
>
> >Thanks.
> >Paul
> >
> >Thomas Kyte wrote:
> >
> >> A copy of this was sent to P Jeromel <pjeromel_at_hotmail.com>
> >> (if that email address didn't require changing)
> >> On Sun, 20 Jun 1999 18:38:30 +0930, you wrote:
> >>
> >> >Hi All,
> >> >
> >> >Does anyone know if there are any packages available which allows bit
> >> >manipulation
> >> >on datatypes (preferably NUMBER or REAL)???
> >> >
> >>
> >> what kind of bit manipulations?
> >>
> >> there is an undocumented 'bitand()' routine you can call.
> >>
> >> If you need bitor, this might do it for you:
> >>
> >> CREATE OR replace FUNCTION bitor( x IN NUMBER, y IN NUMBER ) RETURN NUMBER
> >> AS
> >> l_x PLS_INTEGER DEFAULT x;
> >> l_y PLS_INTEGER DEFAULT y;
> >> l_r PLS_INTEGER DEFAULT 0;
> >> l_tmp PLS_INTEGER := 1;
> >> BEGIN
> >> FOR i IN 1 .. 32 LOOP
> >> IF ( bitand(l_x,l_tmp) = l_tmp OR bitand(l_y,l_tmp) = l_tmp )
> >> THEN
> >> l_r := l_r + l_tmp;
> >> END IF;
> >> l_tmp := l_tmp * 2;
> >> exit when ( l_tmp >= l_x AND l_tmp >= l_y );
> >> END LOOP;
> >>
> >> RETURN l_r;
> >> END;
> >> /
> >>
> >> that function is callable from sql as well. both bitand and the above bitor
> >> only work with 32bit integers (don't work with abs(numbers) > 2^31)
> >>
> >> >I know of the UTL_RAW with it's functions/procedures.
> >> >
> >>
> >> >(It's for a small Data Conversion job - so I would rather not write
> >> >something too large to do the job).
> >> >
> >> >Is there anything else out there which comes with 8.0.5 Workgroup
> >> >Server?
> >> >
> >> >Thanks.
> >> >Paul
> >> >
> >>
> >> --
> >> See http://govt.us.oracle.com/~tkyte/ for my columns 'Digging-in to Oracle8i'...
> >> Current article is "Fine Grained Access Control", added June 8'th
> >>
> >> Thomas Kyte tkyte_at_us.oracle.com
> >> Oracle Service Industries Reston, VA USA
> >>
> >> Opinions are mine and do not necessarily reflect those of Oracle Corporation
>
> --
> See http://govt.us.oracle.com/~tkyte/ for my columns 'Digging-in to Oracle8i'...
> Current article is "Fine Grained Access Control", added June 8'th
>
> Thomas Kyte tkyte_at_us.oracle.com
> Oracle Service Industries Reston, VA USA
>
> Opinions are mine and do not necessarily reflect those of Oracle Corporation
Received on Sun Jun 20 1999 - 20:52:21 CDT

Original text of this message

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