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 #23891 is a reply to message #23889] Mon, 26 February 2001 16:07 Go to previous message
Martin Downing is currently offline  Martin Downing
Messages: 136
Registered: September 1998
Senior Member
"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: Fri Oct 10 09:23:41 PDT 2025

Total time taken to generate the page: 0.80269 seconds