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

Home » Public Forums » archive » Re: bits from bytes
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: bits from bytes [message #10661 is a reply to message #10660] Sat, 20 December 1997 00:00 Go to previous messageGo to previous message
Robert Moss is currently offline  Robert Moss
Messages: 74
Registered: February 1996
Member
Kelly Dean wrote:
>
> I need to extract the first 3 bits from a byte.
>
> Any suggestions?
>
> Kelly Dean
> CSU/CIRA

b = 11B ; a byte of data
foo = [ 2^0, 2^1, 2^2, 2^3 ]
bits = ( b AND foo ) ne 0
print, bits[0]
1
print, bits[1]
1
print, bits[2]
0
print, bits[3]
1

I assume of course you have encoded information into each
individual bit. If what you want is the first three bits together,
it would simply be ( b AND 7 ) = 3


--
Robert M. Moss, Ph.D. - mossrm@texaco.com - FAX (713)954-6911
------------------------------------------------------------ -----
This does not necessarily reflect the opinions of Texaco Inc.
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Hooded Mergansers and Other Thoughts
Next Topic: getting procedures to use proper color index via LOADCT, x

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

Current Time: Fri Oct 10 15:02:36 PDT 2025

Total time taken to generate the page: 0.16067 seconds