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

Home » Public Forums » archive » Re: is there a command in IDL like bitget command in matlab?
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
Re: is there a command in IDL like bitget command in matlab? [message #49060] Tue, 13 June 2006 21:56
mmeron is currently offline  mmeron
Messages: 44
Registered: October 2003
Member
In article <zzbatmos-A42A7E.23210713062006@news.tamu.edu>, zzbatmos <zzbatmos@tamu.edu> writes:
> Hi all,
> Does anyone know that whether there is command in IDL to get the value
> of a bit in a integer, just like the bitget command in MATLAB?
>
You can use AND for this purpose. For bit #n (count starts at zero)
of integer x do

bit = (x and 2^n)/2^n

more generally you can generate an array, say for 32 bits, by

arr = 2l^(lindgen(32))

and get all the bits of a given integer by doing

res = (x and arr)/arr

Mati Meron | "When you argue with a fool,
meron@cars.uchicago.edu | chances are he is doing just the same"
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: is there a command in IDL like bitget command in matlab?
Next Topic: Re: iTool identifiers

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

Current Time: Thu Oct 09 14:53:57 PDT 2025

Total time taken to generate the page: 0.88832 seconds