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

Home » Public Forums » archive » print a la C
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: print a la C [message #9107 is a reply to message #9059] Wed, 04 June 1997 00:00 Go to previous messageGo to previous message
knipp is currently offline  knipp
Messages: 68
Registered: January 1993
Member
In article <338D9954.344A@acm.org>, Andrea Spinelli <spinellia@acm.org> writes:
> Hi,
>
> does anybody know whether there is a freely available somewhere a
> function for printing floats in a way similar to the %g
> argument of printf? E.g.:
>
> printf("%g\n",0.02); [C]
> results in
> 0.02
>
> print, 0.01 [IDL]
> 0.0100000
>
> (no extra blanks, no extra zeroes)
>
> Of course, I could say in IDL
>
> print,format='(f4.2)',0.01
>
> but I need something that, without knowing the number of
> digits in advance, makes an earnest effort to save space
> and keep readability (and works, e.g., also with 0.003!!!)
>
> Thanks in advance,
> Andrea Spinelli
> spinellia@acm.org


Andrea,

do something like:

- convert number to string via
s_num = strtrim(string(number), 2)

- get last non-zero char. via strpos

- print

Karl

---
knipp@digitalmap.hi.bosch.de
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Re: Beta just expired, anyone got the new one yet?
Next Topic: Re: IDL FAQ - better format

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

Current Time: Thu Oct 09 20:41:42 PDT 2025

Total time taken to generate the page: 0.72737 seconds