|
Re: Negative values with incrementation [message #70941 is a reply to message #70939] |
Thu, 20 May 2010 17:49  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Suguru Amakubo writes:
> First time round, it gave me a positive number of void as expected and
> I increased the number of points scattered however when I have done so
> the number of void became negative.
> ...
> coverage is a 400x400 matrice containing the number of reference
> points scattered on a certain pixel.
>
> and the output was:
>
> IDL> print, void_point
> -2469
>
> the number of points scattered was 3015 (checked using help)
>
> Any idea why this happens?
You have exceeded the value of a short 16-bit integer.
Make your counting variable a long integer:
void_point = 0L
Or, better yet, make *all* your integers longs by putting
this statement in all of your programs:
Compile_Opt defint32
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|