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

Home » Public Forums » archive » bits into bytes
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
bits into bytes [message #81033] Wed, 01 August 2012 15:49
wlandsman is currently offline  wlandsman
Messages: 743
Registered: June 2000
Senior Member
I have to write an array of "on-off" states in which the values are stored as bits. So if I have

x = [1b,0b,1b,1b,1b,0b,1b,1b]

i want to convert this to a single byte value. (This is the inverse of David Fanning's bitget.pro function.)
One way to to do this is

IDL> yy = [128b,64b,32b,16b,8b,4b,2b,1b]
IDL> print,byte( total(yy*x))
187b

But there must be a way to do this using masking rather than multiplication. I just can't figure it out right now. (The conversion will be done for millions of bits). Thanks, --Wayne
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: A wavelet question
Next Topic: Re: bits into bytes

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

Current Time: Wed Oct 08 17:03:12 PDT 2025

Total time taken to generate the page: 0.00436 seconds