Re: Extracting bits with IDL [message #2594 is a reply to message #2592] |
Mon, 18 July 1994 01:58  |
stl
Messages: 70 Registered: February 1994
|
Member |
|
|
In article <Ct2GM1.1780@yuma.ACNS.ColoState.EDU> dean%phobos.dnet@sirius.cira.colostate.edu writes:
> .....
> contains some time information. Extracting individual bits from data with IDL
> is difficult. At first I consider building an IDL structure, but IDL is
> unable to break down to bits.
kinda sorta not/really (see below)
> The information can fit into LONARR(2). If anyone has any suggestion that
> would allow IDL to extract the information from these LONARR(2), please
> forward your comments to me or post them.
Hi,
okay, to strip a long apart bit by bit, simple test each bit. For
instance if you wish to check if the second bit was set (binary value of
0000 0000 0000 0010) AND it with 2, if the result is 2, the bit was set,
otherwise it was not. This can then be done for each bit, or you could
check groups of bits this way.
I am sure there are other methods of doing this, but this should be
pretty functional method. In IDL do something like the following:
x = 3L ;sample long data, lets test it to see if the second
; bit is set
if (x and 2) eq 2 then print,"second bit set" else $
print,"second bit wasn't set"
-hope this helps, and is what your looking for.
-stephen
--
Stephen C Strebel / SKI TO DIE
strebel@sma.ch / and
Swiss Meteorological Institute, Zuerich / LIVE TO TELL ABOUT IT
01 256 93 85 / (and pray for snow)
|
|
|