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

Home » Public Forums » archive » Controlling number of decimal places
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: Controlling number of decimal places [message #40272 is a reply to message #40207] Thu, 29 July 2004 13:59 Go to previous messageGo to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Edwin writes:

> Sorry I'm still having trouble with this. I didn't fully explain my
> problem.
>
> The complete situation is that I have two DOUBLE variables. Say A and
> B, each holding a number with 5 decimal places, ex. 200.52343
>
> I want to output these two numbers rounded to two decimal places to a
> text file using PRINTF in the following format (with the comma):
>
> A,B
>
> So If my numbers were 560.34345 and 780.93434, I want my text file to
> read:
>
>
> 560.34,780.93
>
>
>
> David, I have tried your suggestion about the PRINTF format codes, but
> I am having trouble getting it to work:
>
> I can either write:
>
> printf, 1, A, FORMAT='(F8.2)'
> printf, 1, ','
> printf, 1, B, FORMAT='(F8.2)'
>
> which leads to all three entries being on separate lines.
>
> or I can write:
>
> printf, 1, A, ',', B, FORMAT='(F8.2)'
>
> which also doesn't work since the FORMAT code doesn't know what to do
> with the comma in between.
>
> The only solution I can think of is not to use FORMAT codes but to use
> some kind of rounding up function...Any ideas?

How about this:


IDL> x=560.34345
IDL> y=780.93434
IDL> Print, x, y, format='(2(f6.2,:,","))'
560.34,780.93

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Programatically create structure
Next Topic: Displaying fluid flow in porous medium

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

Current Time: Sat Oct 11 15:59:56 PDT 2025

Total time taken to generate the page: 0.46711 seconds