comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Decomposing a bit field?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Decomposing a bit field? [message #71807 is a reply to message #71716] Wed, 21 July 2010 04:25 Go to previous messageGo to previous message
rjp23 is currently offline  rjp23
Messages: 97
Registered: June 2010
Member
On Jul 21, 11:29 am, Steve <f...@k.e> wrote:
> Rob wrote:
>> for i=0, 31 do begin test[i]=(ISHFT((15982561),-i) AND 1B)
>
>> However, for example bits 1-4 need to be combined (and contain data
>> from 0-15). As I don't quite understand what the code above is doing
>> I'm not sure how to (or if it can be) modified to not just operate on
>> the individual bits but on groups of bits.
>
> ISHFT - moves bits right or left so that the bits you want are at the
> end of the value.  AND selects the bits that you want.
>
>
>
>> What I need to extract is the information in the folowing form:
>
>> Bit 0:  0 or 1
>
> bit0= ishft(15982561,0) and 1B
>
>> Bits 1-4: 0-15
>
> bits1to4 = ishft(15982561,-1) and 17B
>
>> Bit 5: 0 or 1
>
> bit5 = ishft(15982561,-5) and 1B
>
>> Bits 6-8: 0-8
>
> bits6to8 = ishft(15982561,-6) and 7B
>
>> etc
>
>> Thanks in advance
>
>

Thanks everyone, that makes much more sense now.

I just wanted to confirm where the 7B comes from above.

I assume it's because I'm checking 3 bits so it's 1+2+4. If I had a
group of 4 bits it's be 1+2+4+8 (15 like in Chris's example below),
right?
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Read these data in structure
Next Topic: Re: Read these data in structure

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 16:35:52 PDT 2025

Total time taken to generate the page: 0.56006 seconds