IDL out of the for loop

IDL is old. Grandfatherly, even. When it was first written, you had a really souped-up computer if you had added an additional 10 MByte hard drive to go with the standard 1 MByte of disk space. So, you can maybe understand why the default integer size in IDL is 16-bits, or two bytes. This is a short integer by any current standards. This causes problems because a 16-bit signed integer can only represent the values -32768 to 32768. Occasionally, you need an integer larger than that, and even throwing in fingers and toes doesn't do the job.

One place where it causes problems is when short integers are used as counters in FOR loops.

    FOR j=0,n DO ...

If you want your loop to go beyond 32768 (loop values will become negative it they go beyond their bounds), you will have to make your loop variable a long integer, like this.

   FOR j=0L,n DO ....

你可能感兴趣的:(IDL out of the for loop)