handling numbers [message #33179] |
Fri, 13 December 2002 08:43  |
Steve.Morris
Messages: 17 Registered: November 2002
|
Junior Member |
|
|
Hi!
I am stuck on a problem, probably it is very easy, but I don't know the solutions!
I have a list of number in this form:
000237.9
000246.3
000257.0
........
and I would like to write them in this form:
00 02 37.9
00 02 46.3
00 02 57.0
Is there any command that can do this?
Thank you very much!
Steve
|
|
|
Re: handling numbers [message #33244 is a reply to message #33179] |
Sun, 15 December 2002 13:13  |
Mark Hadfield
Messages: 783 Registered: May 1995
|
Senior Member |
|
|
<wmc@bas.ac.uk> wrote in message news:3dfa6197@news.nwl.ac.uk...
> Richard Adams <rja46@cam.ac.uk> wrote:
>>> 000237.9
>>>
>>> and I would like to write them in this form:
>>> 00 02 37.9
>
>> a = '000235.8'
>> print, (STREGEX(a, '(..)(..)(....)', /SUBEXPR, /extract))[1:*]
>> 00 02 35.8
>
> In other words, use perl...
a = '000235.8'
b = byte(a)
print, string(b[0:1]), ' ', string(b[2:3]), ' ', string(b[4:*])
Eat your heart out, Perl...
--
Mark Hadfield "Ka puwaha te tai nei, Hoea tatou"
m.hadfield@niwa.co.nz
National Institute for Water and Atmospheric Research (NIWA)
|
|
|