Re: 4 byte integers [message #66822] |
Fri, 12 June 2009 16:26  |
Michael Galloy
Messages: 1114 Registered: April 2006
|
Senior Member |
|
|
On Jun 12, 5:19 pm, Joshua Von Korff <joshlegan...@hotmail.com> wrote:
> Is there any way I can set a flag to force IDL to consider all
> integers as having 4 bytes? It's happened many times that I assume a
> number won't go above 32768, and then months later, it does go above.
> This produces an error that can be annoying to track down. So I've
> taken to writing 0L, 1L, 2L, lindgen() at all times, but sometimes I
> forget. Any thoughts?
>
> It's not even clear to me that IDL is saving any time by restricting
> to 2 bytes ... aren't they represented as 4 bytes at some lower level
> anyway?
Try "comile_opt defint32" (or "compile_opt idl2" which also throws in
the "strictarr" option which I recommend):
IDL> help, 0
<Expression> INT = 0
IDL> compile_opt defint32
IDL> help, 0
<Expression> LONG = 0
The catch is that it still needs to be done on a routine by routine
basis (there is no "master switch" to throw for this).
Mike
--
www.michaelgalloy.com
Associate Research Scientist
Tech-X Corporation
|
|
|
Re: 4 byte integers [message #66966 is a reply to message #66822] |
Mon, 15 June 2009 03:10  |
Maarten[1]
Messages: 176 Registered: November 2005
|
Senior Member |
|
|
On Jun 13, 1:26 am, Mike Galloy <mgal...@gmail.com> wrote:
> On Jun 12, 5:19 pm, Joshua Von Korff <joshlegan...@hotmail.com> wrote:
>
>> Is there any way I can set a flag to force IDL to consider all
>> integers as having 4 bytes? It's happened many times that I assume a
>> number won't go above 32768, and then months later, it does go above.
>> This produces an error that can be annoying to track down. So I've
>> taken to writing 0L, 1L, 2L, lindgen() at all times, but sometimes I
>> forget. Any thoughts?
>
> Try "comile_opt defint32" (or "compile_opt idl2" which also throws in
> the "strictarr" option which I recommend):
[snip]
> The catch is that it still needs to be done on a routine by routine
> basis (there is no "master switch" to throw for this).
For interactive use, you can put the compile_opt idl2 in your startup
script. This will cover the command-line, but not compiled functions
as Mike already said. I wish there was a master switch, and for float/
double as well.
Maarten
|
|
|