Re: Please explain... [message #5397 is a reply to message #5253] |
Mon, 27 November 1995 00:00   |
Ding Wu - see John Vo
Messages: 1 Registered: November 1995
|
Junior Member |
|
|
Please note:
The NOT operator is the Boolean inverse and is
a unary operator because it has only one operand.
In other words, "NOT true" is equal to "false"
and "NOT false" is equal to "true." NOT complements
each bit for integer operands. For floating-point
operands, the result is 1.0 if the operand is zero;
otherwise, the result is zero.
So
1: if change x=0 & y=0 to x=.0 & y=.0 then all will work.
For x=0 & y=0 , ( not x and not y) is (not 0000 and not 0000) ie. -1,
For x=.0 & y=.0, ( not x and not y) is 1.0
2: in the case statement, each of the conditions must be
matched to 1.
so, case statement ( not x and not y = -1 ) found no matches.
3: but in if statement, the conditions only need to be
not zero.
so, if statement ( not x and not y = -1 ) is true.
Ding Wu, need a job, desperately!
mallozzi@ssl.msfc.nasa.gov wrote: : Can someone explain this
to me?
: IDL> .r
: - x = 0 & y = 0
: - case 1 of
: - x and y: print, '1'
: - NOT x and y: print, '2'
: - x and NOT y: print, '3'
: - NOT x and NOT y: print, '4'
: - endcase
: - end
: % Compiled module: $MAIN$.
: % Case statement found no matches.
: % Execution halted at $MAIN$ </dev/tty( 1)> .
: IDL> if NOT x and NOT y then print, '4'
: 4
: IDL>
: The other three cases work as I expected in the case statement. Thanks.
: -Bob
|
|
|