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

Home » Public Forums » archive » Re: significant figures function?
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: significant figures function? [message #23882] Mon, 26 February 2001 18:33 Go to previous message
Med Bennett is currently offline  Med Bennett
Messages: 109
Registered: April 1997
Senior Member
Thanks Ben and Martin! I had already kluged together another solution using a
routine I found using the search engine I found using
http://www.astro.washington.edu/deutsch/idl/htmlhelp/index.h tml (very handy
tool!) by searching for 'significant' called strnsignif.pro
( http://www.astro.washington.edu/deutsch-bin/getpro/library03 .html?STRNSIGNIF).
Wrapping this with a loop and converting back to float did the trick. Less
than perfect, but in the consulting biz, whatever can be found quickly beats
an elegant solution!

Med

Martin Downing wrote:

> "Med Bennett" <mbennett@indra.com> wrote in message
> news:3A9ACD30.E0F3F5D9@indra.com...
>> Has anyone written a function that returns the input value or array with
>> a specified number of significant digits? I have lloked at the various
>> IDL libraries on the web but did not come up with what I'm after.
>> Thanks in advance for any pointers -
>>
>
> this should do it
>
> function fix_digits, num, digits
> expon = 1.0
> while num/expon gt 1 do expon = expon * 10
> fix_val = num/expon
> fstring = string(digits+2, digits, format = '("(f",i0.0,".",i0.0,")")')
> reads, string(fix_val, format = fstring), fix_val
> return, fix_val * expon
> end
>
>> print, fix_digits(!pi, 3)
> 3.14000
>
> Martin
>
> ----------------------------------------
> Mr. Martin Downing,
> Clinical Research Physicist,
> Orthopaedic RSA Research Centre,
> Woodend Hospital,
> Aberdeen, AB15 6LS.
> m.downing@abdn.ac.uk
>
> Martin
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Running IDL from cron
Next Topic: IDL programmers required

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

Current Time: Wed Oct 08 16:03:24 PDT 2025

Total time taken to generate the page: 0.00201 seconds