Re: very simple Index question~~~help~~~ [message #62531] |
Tue, 16 September 2008 09:35 |
R.G. Stockwell
Messages: 363 Registered: July 1999
|
Senior Member |
|
|
"xiao" <littledddna@gmail.com> wrote in message
news:1e78d923-49cd-4480-978d-d742c71aa7ca@m45g2000hsb.google groups.com...
> I have a very simple question , I have an 178*300 array, I want to
> read it line by line like this :
>
> print,diff(53399)
> print,diff(178*299+177) ;178*299+177=53399
IDL> print,178*299+177
-12137
|
|
|
Re: very simple Index question~~~help~~~ [message #62532 is a reply to message #62531] |
Tue, 16 September 2008 08:54  |
xiao zhang
Messages: 81 Registered: June 2008
|
Member |
|
|
On Sep 16, 3:22 am, Carsten Lechte <c...@toppoint.de> wrote:
> xiao wrote:
>> I have a very simple question , I have an 178*300 array, I want to
>> read it line by line like this :
>
>> print,diff(53399)
>
> This works, and this
>
>> print,diff(178*299+177) ;178*299+177=53399
>
> does not? Try
>
> PRINT, 178*299+177
>
> and you will probably see a negative number.
>
> Visithttp://www.dfanning.com/code_tips/mostcommon.htmland read
> "Problems Caused by Short Integers". Swearing is optional;-)
>
> chl
hmm...very smart :)
|
|
|
|
Re: very simple Index question~~~help~~~ [message #62542 is a reply to message #62541] |
Tue, 16 September 2008 00:09  |
xiao zhang
Messages: 81 Registered: June 2008
|
Member |
|
|
On Sep 15, 10:59 pm, David Fanning <n...@dfanning.com> wrote:
> xiao writes:
>> I think it is over floating.......How can I solve this?
>
> Try making your loop counter a LONG integer:
>
> FOR j=0L, n DO ...
>
> Or, even better, make *all* your integers LONG integers:
>
> COMPILE_OPT defint32
>
> Here is an article you probably ought to read:
>
> http://www.dfanning.com/code_tips/mostcommon.html
>
> 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.")
Thank you very much, David :)
|
|
|
|
Re: very simple Index question~~~help~~~ [message #62544 is a reply to message #62543] |
Mon, 15 September 2008 20:56  |
xiao zhang
Messages: 81 Registered: June 2008
|
Member |
|
|
On Sep 15, 10:49 pm, David Fanning <n...@dfanning.com> wrote:
> xiao writes:
>> I have a very simple question , I have an 178*300 array, I want to
>> read it line by line like this :
>
>> print,diff(53399)
>> print,diff(178*299+177) ;178*299+177=53399
>
>> for i=0,177 do begin
>> diff2(i)= diff(178*299+i)
>> endfor
>
>> Why it always remind me that it out of range in the second print
>> statement. I mean 178*299+177 s exactly equal to 53399.
>
> IDL arrays are indexed starting from 0 and not 1. If you
> get to 53399, you have exceeded the bounds of the array,
> which go from index 0 to 53398.
>
> 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.")
I think it is over floating.......How can I solve this?
TNX
|
|
|
Re: very simple Index question~~~help~~~ [message #62545 is a reply to message #62544] |
Mon, 15 September 2008 20:49  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
xiao writes:
> I have a very simple question , I have an 178*300 array, I want to
> read it line by line like this :
>
> print,diff(53399)
> print,diff(178*299+177) ;178*299+177=53399
>
> for i=0,177 do begin
> diff2(i)= diff(178*299+i)
> endfor
>
>
> Why it always remind me that it out of range in the second print
> statement. I mean 178*299+177 s exactly equal to 53399.
IDL arrays are indexed starting from 0 and not 1. If you
get to 53399, you have exceeded the bounds of the array,
which go from index 0 to 53398.
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.")
|
|
|