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

Home » Public Forums » archive » Re: printing floats/integer
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: printing floats/integer [message #24111 is a reply to message #24110] Thu, 08 March 2001 08:00 Go to previous messageGo to previous message
Klaus Scipal is currently offline  Klaus Scipal
Messages: 45
Registered: November 1997
Member
the only solution to your problem I would come up with is doing it in a loop
recursively but i am afraid this is not very elegant

klaus


Sean Heukels <sean77=cuthere=@dds.nl> wrote in message
news:9884hb$coo$1@newshost.accu.uu.nl...
>
> What if I dont know that the float will
> be 8 in length and has 6 decimals ??
>
> How can we put this in a subroutine, that handles
> a variable (e.g. PRO FORMAT, var1) and returns
> the right way to print ??
>
> For the int I use
>
> PRO FORMAT, var
> which=SIZE(var, /TYPE)
> if (which eq 2) then begin
> le=FLOOR(ALOG10(var)) + 1
> RETURN, STRING(var, FORMAT='(I'+STRTRIM(STRING(le))+')'
> endif else if (which eq 4) then begin
>
> How do I do this for a float >>>??
> 1.22222200000 must become 1.22222 without leading or trailing spaces.
> And in the best scenario 1.00 doesn;t become 1., but 1.0 ....
>
>
>
> Sean
>
>
> Klaus Scipal <kscipal@ipf.tuwien.ac.at> schreef in berichtnieuws
> 9882vb$sbi$1@news.tuwien.ac.at...
>> you can use the the string command in connection with format
>>
>> for example
>> IDL> x=1.222221000000000000000
>> IDL> print, string(format='(f8.6)',x)
>> 1.222221
>>
>> klaus
>>
>> Sean Heukels <sean77=cuthere=@dds.nl> wrote in message
>> news:9881p0$55o$1@newshost.accu.uu.nl...
>>> I wrote a small module for integers. The variable is formatted and
>> returned.
>>>
>>> "1 " returns as "1"
>>>
>>> Now this doesn't work with floats. for example if I want to print
>> "1.22221"
>>> I
>>> dont want to see it as "1.222221000000000000000" or
>>> "1.222222 "
>>>
>>> Does anyone know how I can solve this ??
>>>
>>> Greets Sean
>>>
>>>
>>
>>
>
>
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: contour labels question
Next Topic: Color 'n linestyle picker for Plot

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

Current Time: Fri Oct 10 06:36:39 PDT 2025

Total time taken to generate the page: 0.88145 seconds