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

Home » Public Forums » archive » Re: SPLIT numbers into sub-numbers
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: SPLIT numbers into sub-numbers [message #80580 is a reply to message #80577] Sat, 23 June 2012 15:08 Go to previous messageGo to previous message
k_ghreep is currently offline  k_ghreep
Messages: 19
Registered: May 2012
Junior Member
On Jun 23, 11:13 pm, Carsten Lechte <c...@toppoint.de> wrote:
> On 23/06/12 03:45, Kenneth P. Bowman wrote:
>
>> year  = 0
>> month = 0
>> day   = 0
>> READS, ts, year, month, day, FORMAT = "(I4,2I2)"
>
> Nice, I had not thought of that.
>
> My first idea was:
>
> num = 20100115L ; very important: force LONG integer type!
> y = num/10000
> m = (num-y*10000)/100
> d = num - y*10000 - m*100
> print, num, y, m, d
>
> ==>    20100115        2010           1          15
>
> chl

for the following array
20100101 20100101 20100101 20100101 20100102
20100102 20100102 20100102 20100103 20100103
20100103 20100103 20100104

I wrote

y=lonarr( n_elements(num))
m =lonarr( n_elements(num))
d =lonarr( n_elements(num))
for i = 0, n_elements(num)-1 do begin
num(i)=num(i)+0L

y(i) = num(i)/10000
m(i) = (num(i)-y(i)*10000)/100
d(i) = num(i) - y(i)*10000 - m(i)*100
print, num(i), y(i), m(i), d(i)
endfor

and now ran correctly with the following output
20100101 2010 1 1
20100101 2010 1 1
20100101 2010 1 1
20100101 2010 1 1
20100102 2010 1 2
20100102 2010 1 2
20100102 2010 1 2
20100102 2010 1 2
20100103 2010 1 3
20100103 2010 1 3
20100103 2010 1 3
20100103 2010 1 3
20100104 2010 1 4
thank you for your helping
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: astronomy library
Next Topic: Re: Coyote graphics resizeable window

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

Current Time: Wed Oct 08 19:58:49 PDT 2025

Total time taken to generate the page: 0.00409 seconds