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

Home » Public Forums » archive » How to plot multiple charts and ho to round float to specific precision?
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: How to plot multiple charts and ho to round float to specific precision? [message #44959 is a reply to message #44858] Thu, 28 July 2005 15:45 Go to previous messageGo to previous message
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
Benjamin Hornberger wrote:
> Paul Van Delst wrote:
>
>> liko2@o2.pl wrote:
>>
>>> No, it has to be a value of variable, later used for a part of title of
>>> a chart. So it has to be exact value with only 2 digits after zero.
>>>
>>
>> Given your floating point variable,
>>
>> IDL> x=23.45654
>> IDL> print, x
>> 23.4565
>>
>> you can stick it into a string variable
>>
>> IDL> cx=string(x,format='(f15.2)')
>> IDL> help, cx
>> CX STRING = ' 23.46'
>>
>> Note I used the format f15.2 since you might have a number like
>>
>> IDL> y=7140264.38264
>> IDL> cy=string(y,format='(f15.2)')
>> IDL> help, cy
>> CY STRING = ' 7140264.38'
>>
>> You'll want to leave enough room up front (via the "15" in f15.2) for
>> the extra digits.
>>
>> And then you can crop the above results to your heart's content:
>>
>> IDL> help, strtrim(cx,2), strtrim(cy,2)
>> <Expression> STRING = '23.46'
>> <Expression> STRING = '140264.38'
>>
>> for your plot titles.
>>
>> paulv
>>
>
> Can't you just use a "0" in the format string ('(f0.2)') instead of
> using a large number first and then trimming the string?

I tried that first (based on your original post) but it didn't work for me.

IDL> print, !version
{ x86 linux unix linux 6.0.3 Feb 26 2004 32 64}
IDL> x=23.45654
IDL> cx=string(x,format='(f0.2)')
IDL> help, cx
CX STRING = '23.456539'
IDL> y=7140264.38264
IDL> cy=string(y,format='(f0.2)')
IDL> help, cy
CY STRING = '7140264.500000'

Dunno why not.

paulv

--
Paul van Delst
CIMSS @ NOAA/NCEP/EMC
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: CALL_EXTERNAL and C++ code
Next Topic: Re: Multilayered plots

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

Current Time: Sat Nov 29 05:16:50 PST 2025

Total time taken to generate the page: 1.04014 seconds