Yet another bug?? [message #4290] |
Wed, 17 May 1995 00:00  |
phil
Messages: 15 Registered: April 1995
|
Junior Member |
|
|
Sorry to keep posting but I've just started developing some useful
tools in IDL and it seems I run across a new 'bug' every day. Could
someone tell me the sense behind the following:
IDL> print, not 0
-1
IDL> print, not 1
-2
Shouldn't (not 0) = 1 and (not 1) = 0 or am i just missing something?
Is there somehting in the manuals that describes this logic?
Just wondering.
--
/*********************************************************** ****************/
Phil Williams
Postdoctoral Researcher "One man gathers what
MRI Facility another man spills..."
The Ohio State University -The Grateful Dead
email: phil@peace.med.ohio-state.edu
URL: http://justice.med.ohio-state.edu:1525
/*********************************************************** ****************/
|
|
|
Re: Yet another bug?? [message #4395 is a reply to message #4290] |
Wed, 24 May 1995 00:00  |
sjt
Messages: 72 Registered: November 1993
|
Member |
|
|
Phil (phil@peace.med.ohio-state.edu) wrote:
: Sorry to keep posting but I've just started developing some useful
: tools in IDL and it seems I run across a new 'bug' every day. Could
: someone tell me the sense behind the following:
: IDL> print, not 0
: -1
: IDL> print, not 1
: -2
: Shouldn't (not 0) = 1 and (not 1) = 0 or am i just missing something?
: Is there somehting in the manuals that describes this logic?
: Just wondering.
The answers are perfectly correct 0 is in hex 0000 and so (not 0) is ffff
which is -1, and not 1 will be fffe or -2. It's a bitwise operation,
often useful but occasionally infuriating (e.g. if you want to use the
negation of something you've just calculated as a value of a set/unset
keyword) if you want the logical operation then you should and the entire
expression with 1
e.g.
IDL>print, (not 0) and 1
1
IDL>print, (not 1) and 1
0
: --
: /*********************************************************** ****************/
: Phil Williams
: Postdoctoral Researcher "One man gathers what
: MRI Facility another man spills..."
: The Ohio State University -The Grateful Dead
: email: phil@peace.med.ohio-state.edu
: URL: http://justice.med.ohio-state.edu:1525
: /*********************************************************** ****************/
--
+------------------------+---------------------------------- --+---------+
| James Tappin, | School of Physics & Space Research | O__ |
| sjt@star.sr.bham.ac.uk | University of Birmingham | -- \/` |
| Ph: 0121-414-6462. Fax: 0121-414-3722 | |
+----------------------------------------------------------- --+---------+
|
|
|