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

Home » Public Forums » archive » Re: how to do bitwise operation in IDL???
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: how to do bitwise operation in IDL??? [message #9597] Fri, 25 July 1997 00:00 Go to previous message
Stein Vidar Hagfors H is currently offline  Stein Vidar Hagfors H
Messages: 32
Registered: May 1997
Member
William Thompson wrote:
>
> jyli@redback.gsfc.nasa.gov (Jason Li) writes:
>
>> Hi,
>
>> I need to read and set a seris of image processing flags which are
>> packed into byte size variables. Except the ISHIFT, I could not find
>> any other bitwise operators in IDL language.
>
>> OK, I can always call C or FORTRAN routines from IDL to accomplish this
>> task. But, is there a simplier way to read set bits in IDL ? After all,
>> IDL is built on C, isn't it?
>
> As well as the ISHFT function, IDL also contains the bitwise logical operators
> AND and OR. For example, if you wanted the value of the 3rd bit from the right
> in a byte value, then you could say
>
> VALUE = ISHFT(INPUT,-3) AND 1
>
> or
>
> VALUE = (INPUT AND '8'X) NE 0
>

And even though you can implement any logical operation with AND, OR
and NOT (I seem to remember that the pairs NOT+AND or NOT+OR will do
as well?), there's also an operator for exclusive or - called XOR,
as in

VALUE = A XOR 1

which will flip the least significant bit of A..

Stein Vidar
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Re: problem with program code area full in VMS IDL 4.0.1
Next Topic: IDL V5 and Pointers

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

Current Time: Sat Oct 11 15:02:35 PDT 2025

Total time taken to generate the page: 0.95758 seconds