[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: subtle but important
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.