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

Home » Public Forums » archive » Re: representive digits
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: representive digits [message #29123] Tue, 05 February 2002 09:04
R.Bauer is currently offline  R.Bauer
Messages: 1424
Registered: November 1998
Senior Member
James Kuyper wrote:
>
> Reimar Bauer wrote:
>
>> Hi,
>>
>>
>> I am searching for a routine to copy numbers to their
>> representive digits in a string.
>>
>> e.g
>>
>> float : 6 digits
>>
>> numbers=[(1/3.)*1000., !pi*10000.]
>>
>> print,numbers,format='(F20.5)'
>>
>> gives a fix mask and returns:
>>
>> 333.33334
>> 31415.92773
>>
>>
>> what I like to have is :
>>
>> 333.333
>> 31415.9
>>
>> Any ideas ?
>>
>>
>> Reimar
>
> printf,numbers,format='(G7.6)'

That's the one I am looking for

print,double(string(numbers,format='(G7.6)')),format='(F20.8 )'

333.33300000
31415.90000000


Thanks

Reimar

--
Reimar Bauer

Institut fuer Stratosphaerische Chemie (ICG-1)
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
http://www.fz-juelich.de/icg/icg1/
============================================================ ======
a IDL library at ForschungsZentrum Juelich
http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_lib_intro.h tml

http://www.fz-juelich.de/zb/text/publikation/juel3786.html
============================================================ ======
Re: representive digits [message #29125 is a reply to message #29123] Tue, 05 February 2002 09:01 Go to previous message
R.Bauer is currently offline  R.Bauer
Messages: 1424
Registered: November 1998
Senior Member
James Kuyper wrote:
>
> Reimar Bauer wrote:
>
>> Hi,
>>
>>
>> I am searching for a routine to copy numbers to their
>> representive digits in a string.
>>
>> e.g
>>
>> float : 6 digits
>>
>> numbers=[(1/3.)*1000., !pi*10000.]
>>
>> print,numbers,format='(F20.5)'
>>
>> gives a fix mask and returns:
>>
>> 333.33334
>> 31415.92773
>>
>>
>> what I like to have is :
>>
>> 333.333
>> 31415.9
>>
>> Any ideas ?
>>
>>
>> Reimar
>
> printf,numbers,format='(G7.6)'

that's the best

print,float(string(numbers,format='(G7.6)'))


Thanks

Reimar
--
Reimar Bauer

Institut fuer Stratosphaerische Chemie (ICG-1)
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
http://www.fz-juelich.de/icg/icg1/
============================================================ ======
a IDL library at ForschungsZentrum Juelich
http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_lib_intro.h tml

http://www.fz-juelich.de/zb/text/publikation/juel3786.html
============================================================ ======
Re: representive digits [message #29134 is a reply to message #29125] Mon, 04 February 2002 07:28 Go to previous message
James Kuyper is currently offline  James Kuyper
Messages: 425
Registered: March 2000
Senior Member
Reimar Bauer wrote:

> Hi,
>
>
> I am searching for a routine to copy numbers to their
> representive digits in a string.
>
> e.g
>
> float : 6 digits
>
> numbers=[(1/3.)*1000., !pi*10000.]
>
> print,numbers,format='(F20.5)'
>
> gives a fix mask and returns:
>
> 333.33334
> 31415.92773
>
>
> what I like to have is :
>
> 333.333
> 31415.9
>
> Any ideas ?
>
>
> Reimar

printf,numbers,format='(G7.6)'
Re: representive digits [message #29135 is a reply to message #29134] Mon, 04 February 2002 07:18 Go to previous message
R.Bauer is currently offline  R.Bauer
Messages: 1424
Registered: November 1998
Senior Member
Andrea Pitacco wrote:
>
> On Mon, 04 Feb 2002 13:46:58 +0100, Reimar Bauer
> <r.bauer@fz-juelich.de> wrote:
>
>> Hi,
>>
>>
>> I am searching for a routine to copy numbers to their
>> representive digits in a string.
>>
>> e.g
>>
>> float : 6 digits
>>
>> numbers=[(1/3.)*1000., !pi*10000.]
>>
>> print,numbers,format='(F20.5)'
>>
>> gives a fix mask and returns:
>>
>> 333.33334
>> 31415.92773
>>
>>
>> what I like to have is :
>>
>> 333.333
>> 31415.9
>>
>> Any ideas ?
>
> IDL> numbers=[(1/3.)*1000., !pi*10000.]
> IDL> digNo=6
>
> IDL> Print, StrMid(StrTrim(String(Float(numbers)),2),0,digNo+1)
> 333.333 31415.9
>
> Andrea

Good idea

first result is:

IDL> numbers=[(1/3.)*1000., !pi*10000.]
IDL> digNo=6

IDL> x=StrMid(StrTrim(String(Float(numbers)),2),0,digNo+1)

IDL> fakt=10.0D^ROUND(/L64,ALOG10(numbers ))

IDL> PRINT,fakt*x/fakt,form='(F20.6)'

333.333000
31415.900000

thanks

Reimar


--
Reimar Bauer

Institut fuer Stratosphaerische Chemie (ICG-1)
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
http://www.fz-juelich.de/icg/icg1/
============================================================ ======
a IDL library at ForschungsZentrum Juelich
http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_lib_intro.h tml

http://www.fz-juelich.de/zb/text/publikation/juel3786.html
============================================================ ======
Re: representive digits [message #29137 is a reply to message #29135] Mon, 04 February 2002 06:17 Go to previous message
andrea.pitacco is currently offline  andrea.pitacco
Messages: 1
Registered: February 2002
Junior Member
On Mon, 04 Feb 2002 13:46:58 +0100, Reimar Bauer
<r.bauer@fz-juelich.de> wrote:

> Hi,
>
>
> I am searching for a routine to copy numbers to their
> representive digits in a string.
>
> e.g
>
> float : 6 digits
>
> numbers=[(1/3.)*1000., !pi*10000.]
>
> print,numbers,format='(F20.5)'
>
> gives a fix mask and returns:
>
> 333.33334
> 31415.92773
>
>
> what I like to have is :
>
> 333.333
> 31415.9
>
> Any ideas ?

IDL> numbers=[(1/3.)*1000., !pi*10000.]
IDL> digNo=6

IDL> Print, StrMid(StrTrim(String(Float(numbers)),2),0,digNo+1)
333.333 31415.9

Andrea
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Dialog_Pickfile Question
Next Topic: Re: AMD CPU - pentium way faster? (should be IDL on win2000 faster than IDL on linux)

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

Current Time: Sat Oct 11 05:02:39 PDT 2025

Total time taken to generate the page: 0.56145 seconds