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 #40442 is a reply to message #40272] Wed, 04 August 2004 09:08 Go to previous messageGo to previous message
i-kant is currently offline  i-kant
Messages: 14
Registered: June 2004
Junior Member
David Fanning <davidf@dfanning.com> wrote in message news:<MPG.1b7312f9e76268969897f0@news.frii.com>...
> 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



Thanks david.

works now. :)
[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 02:59:11 PDT 2025

Total time taken to generate the page: 1.19429 seconds