As a first cut, bit 'i' appears to map to a new value
of power(2,i*2-1)*1.5
eg
8th bit set
= 10000000 binary
= 128 decimal
- 1100000000000000 under new scheme
- 49152 decimal
- power(2,8*2-1)*1.5
so you could have something like:
new_num := 0;
x := 1;
for i in 0 .. 7 loop
if bitand(orig_num,x) = x then
new_num := new_num + x*x*3;
end if;
x := x*2
end loop;
or something like that...
Cheers
Connor
- "Bobak, Mark" <Mark.Bobak_at_il.proquest.com> wrote:
> Sorry, first time I sent this, I typoed the mailing
> list address, when I
> cut-and-paste to resend, I forgot the title.....
>
>
> -----Original Message-----
> From: Bobak, Mark
> Sent: Tue 1/6/2004 4:39 AM
> To: Multiple recipients of list ORACLE-L
> Cc:
> Subject:
> Hi,
>
> Well, since I can't sleep, I may as well try solving
> a problem.
>
> This is a bit odd, and I'm trying to think of the
> most efficient way to do
> it. I've set up some bitmaps in my app. Consider
> we have documents that
> we want to sell. In order to be able to sell a
> given doc, we need to have it
> stored in the vault and we also need to have
> negotiated the proper contract
> w/ the publisher. So, I've got two bitmaps, STORAGE
> and PERMISSIONS.
>
> But, here's the hook. There are 8 different types
> of storage, so I have
> an 8 bit mask. However, for every storage type,
> there are two types of
> permission. So, I have a 16 bit permissions mask.
>
> What I'd like to do is take my 8-bit STORAGE mask,
> say it's 10110011
> and convert it to 1100111100001111. Note that all I
> did there was take
> each bit in the input mask, and make the same value
> repeat. So, 0 would
> become 00, 1 would become 11, 10 would become 1100.
> Does that make sense?
> Once I've done that, I can take my STORAGE mask
> that's now stretched to 16
> bits, and directly AND it with my PERMISSIONS mask.
>
> So, my question is: Is there a nice, scalable way
> to take my 8 bits and
> expand them into 16 bits, in the way that I'm
> describing? A clever bit
> twiddling expression would be perfect, but anything
> that's efficient and
> scalable will do. (The end product will be hidden
> behind a view or stored
> procedure.)
>
> Any thoughts, anyone?
>
> Thanks in advance,
>
> -Mark
> --
> Please see the official ORACLE-L FAQ:
> http://www.orafaq.net
> --
> Author: Bobak, Mark
> INET: Mark.Bobak_at_il.proquest.com
>
> Fat City Network Services -- 858-538-5051
> http://www.fatcity.com
> San Diego, California -- Mailing list and web
> hosting services
>
> To REMOVE yourself from this mailing list, send an
> E-Mail message
> to: ListGuru_at_fatcity.com (note EXACT spelling of
> 'ListGuru') and in
> the message BODY, include a line containing: UNSUB
> ORACLE-L
> (or the name of mailing list you want to be removed
> from). You may
> also send the HELP command for other information
> (like subscribing).
>
>
>
> ATTACHMENT part 2 application/ms-tnef
name=winmail.dat
Connor McDonald
web:
http://www.oracledba.co.uk
web:
http://www.oaktable.net
email: connor_mcdonald_at_yahoo.com
"GIVE a man a fish and he will eat for a day. But TEACH him how to fish, and...he will sit in a boat and drink beer all day"
Yahoo! Messenger - Communicate instantly..."Ping"
your friends today! Download Messenger Now
http://uk.messenger.yahoo.com/download/index.html
--
Please see the official ORACLE-L FAQ: http://www.orafaq.net
--
Author: =?iso-8859-1?q?Connor=20McDonald?=
INET: hamcdc_at_yahoo.co.uk
Fat City Network Services -- 858-538-5051 http://www.fatcity.com
San Diego, California -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from). You may
also send the HELP command for other information (like subscribing).
Received on Tue Jan 06 2004 - 07:29:29 CST