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

Home » Public Forums » archive » Re: Logical vs. Bitwise boolean operators
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: Logical vs. Bitwise boolean operators [message #29156 is a reply to message #29155] Fri, 01 February 2002 12:47 Go to previous message
Jeff Guerber is currently offline  Jeff Guerber
Messages: 41
Registered: July 2000
Member
On Fri, 1 Feb 2002, James Kuyper wrote:

> Fortran has the logical boolean operators .AND., .OR., and .NOT., and I
> naively expected the correspondingly named IDL operators to be the same.
> However, in IDL, those are bitwise operators, rather than logical ones
> (my copy of the manual just calls them 'boolean', without specifying
> whether they are logical or bitwise). As a result, the following code
> did not do what I expected:
>
> IF (!D.FLAGS AND 8) AND (ratio LE minrat) THEN BEGIN

James, as an aside, this statement tries use AND both bitwise _and_
logically. But I understand your point...


> I can always code around this limitation. The solution I came up with
> was to change it to:
>
> IF ((!D.FLAGS AND 8) EQ 8) AND (ratio LE minrat) THEN BEGIN

When confronted with a similar situation I like to use "IF ((!D.FLAGS
AND 8) NE 0) ...", which is a little more general.


> However, it seems to me that there should be a better way to do this.

I agree! I've argued for logical operators before, and also for a true
logical variable type like Fortran's. (I find the practice of using
integers for this to be the source of considerable confusion, especially
when coupled with the arcane rules for what's true and what's false, and
the bitwise operators.) But, so far Boulder has not heard.

Jeff Guerber
Raytheon ITSS
NASA/Goddard, code 971
[Message index]
 
Read Message
Read Message
Previous Topic: Tick formatting
Next Topic: Multiple DICOM images

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

Current Time: Sat Oct 11 15:39:50 PDT 2025

Total time taken to generate the page: 0.16306 seconds