Re: ishft(-32768,-1) = 2147467264 ? [message #9338] |
Fri, 20 June 1997 00:00 |
George McCabe
Messages: 23 Registered: June 1997
|
Junior Member |
|
|
mail message quoted below >>>
On Thu, 19 Jun 1997, George McCabe wrote:
> Is it true that IDL interprets the explicitly typed fix(-32768) as a
> negative constant and not as an operator and an unsigned constant?
I guess I have no way of knowing for sure, but what I'd say is that
when parsing "fix(-32768)" IDL says to itself...
i) Hmm, "32768"... that can't be an ordinary integer, so I'll
make it a long.
ii) There's the unary operator "-", so I'll change the sign.
(value is still a long).
iii) Look here, it's a call to FIX, i.e., a request to convert to
an ordinary integer. The argument is a value I can map into the
set of integers, so I'll do that.
Hope this helps
Stephen Ritcey (902)494-3313 (voice) (902)494-5191 (fax)
Physics Dept., Dalhousie Univ., Halifax, N.S., Canada B3H 3J5
end of quoted message <<<
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV VVVVVVVV
George McCabe (HSTX) NASA / GSFC
Tel: (301)286-8283, Fax: (301)286-0212 Code 693, B2 R151
E-mail: george.mccabe@gsfc.nasa.gov Greenbelt, MD 20912
|
|
|
Re: ishft(-32768,-1) = 2147467264 ? [message #9341 is a reply to message #9338] |
Fri, 20 June 1997 00:00  |
George McCabe
Messages: 23 Registered: June 1997
|
Junior Member |
|
|
On Fri, 20 Jun 1997 09:37:31 -0400, Jack Saba wrote:
> From the user's guide (v3.6,p 3-2):
>
> "Inegers with absolute values greater than 32767 are automatically
> promoted to longword type."
>
Jack,
Thank you for pointing that out. It makes ABS() work, since the
absolute value of -32768 is not a member of the short integers. But
when definitions are contradictory I get confused. Ultimately, I am
going to make mistakes in my code, forgetting one or more of the rules.
Still, -32768 is first a short integer and then also a long integer,
in my mind at least.
George
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV VVVVVVVV
George McCabe (HSTX) NASA / GSFC
Tel: (301)286-8283, Fax: (301)286-0212 Code 693, B2 R151
E-mail: george.mccabe@gsfc.nasa.gov Greenbelt, MD 20912
|
|
|
Re: ishft(-32768,-1) = 2147467264 ? [message #9355 is a reply to message #9338] |
Thu, 19 June 1997 00:00  |
George McCabe
Messages: 23 Registered: June 1997
|
Junior Member |
|
|
> (Can't remember what the IDL equivilent of info is...)
the IDL equivalent to info is help
> Basically, IDL parses '-' as the unary operator, operating on an
> unsigned constant, not as part of the constant. This problem
> arises in other languages which lack explicit typing of embedded
> constants.
Is it true that IDL interprets the explicitly typed fix(-32768) as a
negative constant and not as an operator and an unsigned constant?
Thanx for the mail.
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV VVVVVVVV
George McCabe (HSTX) NASA / GSFC
Tel: (301)286-8283, Fax: (301)286-0212 Code 693, B2 R151
E-mail: george.mccabe@gsfc.nasa.gov Greenbelt, MD 20912
reply to mail message quoted below>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Basically, because 32768 is a long integer. When IDL parses the
line of code
x=-32768
it sees it as
"x becomes equal to the additive inverse of 32768"
Since 32678 is greater than the biggest possible integer, it is
made a long integer. Compare the following
WAVE> x=-32768
WAVE> info, x
X LONG = -32768
WAVE> x=-32767-1
WAVE> info, x
X INT = -32768
(Can't remember what the IDL equivilent of info is...)
Basically, IDL parses '-' as the unary operator, operating on an
unsigned constant, not as part of the constant. This problem
arises in other languages which lack explicit typing of embedded
constants.
Cheers, Stephen
Stephen Ritcey (902)494-3313 (voice) (902)494-5191 (fax)
Physics Dept., Dalhousie Univ., Halifax, N.S., Canada B3H 3J5
|
|
|