comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: subtle but important
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: subtle but important [message #24908] Fri, 27 April 2001 09:12
Paul van Delst is currently offline  Paul van Delst
Messages: 364
Registered: March 1997
Senior Member
Craig Markwardt wrote:
>
> Randall Skelton <rhskelto@atm.ox.ac.uk> writes:
>> On Fri, 27 Apr 2001, Liam E. Gumley wrote:
>>
>>> This is a subtle but important point. DOUBLE() is a type conversion
>>> function [snip]
>>
>> While we are on the subject of 'subtle but important points' in IDL...
>>
>> I also learned today that for integers the default length is 16-bit unless
>> you use the "COMPILE_OPT DEFINT32" statement. Try "print, 1000*1000" in
>> IDL.
>
> Appending "L" to integers saves a lot of grief later on.

This is an understatement

Maybe it's my fortran background, but I always stick an "L" on the end of integers so I
know (and others who read the code after me) that this value is a LONG (read: 4 byte)
integer, even for silly stuff like

n = 3L
FOR i = 0L, n - 1L DO BEGIN
.....
ENDFOR

In this case there's no need but one day someone might make "n" greater than what a 2-byte
int can hold.

Don't they teach this sort of stuff (and the floating point representation stuff) in
computing/science courses anymore?

paulv

--
Paul van Delst A little learning is a dangerous thing;
CIMSS @ NOAA/NCEP Drink deep, or taste not the Pierian spring;
Ph: (301)763-8000 x7274 There shallow draughts intoxicate the brain,
Fax:(301)763-8545 And drinking largely sobers us again.
paul.vandelst@noaa.gov Alexander Pope.
Re: subtle but important [message #24911 is a reply to message #24908] Fri, 27 April 2001 08:28 Go to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
Randall Skelton <rhskelto@atm.ox.ac.uk> writes:
> On Fri, 27 Apr 2001, Liam E. Gumley wrote:
>
>> This is a subtle but important point. DOUBLE() is a type conversion
>> function [snip]
>
> While we are on the subject of 'subtle but important points' in IDL...
>
> I also learned today that for integers the default length is 16-bit unless
> you use the "COMPILE_OPT DEFINT32" statement. Try "print, 1000*1000" in
> IDL.

That's why I often use "print, 1000L*1000L". Appending "L" to
integers saves a lot of grief later on. The COMPILE_OPT approach
works in newer versions, but not in IDL 5.2 or older.

Craig

--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: 2 variables on same plot?
Next Topic: Incrementing an Array

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 12:20:13 PDT 2025

Total time taken to generate the page: 0.64448 seconds