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 #23884 is a reply to message #23882] Mon, 26 February 2001 17:36 Go to previous messageGo to previous message
Martin Downing is currently offline  Martin Downing
Messages: 136
Registered: September 1998
Senior Member
"Ben Tupper" <pemaquidriver@tidewater.net> wrote in message
news:3A9AEA4B.E6169330@tidewater.net...
> You try the following.
>
> ;------start
> ;+
> ; NAME:
> ; ROUNDPV
> ;

hm, I got funny results with this (as i did with my other attempt!)

IDL> print, roundPV( [ 0.0002323,34.3434,1234000], 2)
0.000000 0.000000 1.23400e+006

so I had another think:

function fix_digits, num, digits
p10 = floor(alog10(abs(num)))
expo = 10.0d^(digits -1 - p10)
fix_val = long(num*expo)/expo
return, fix_val
end

this seems to be fine for all thise who dont care about casting to double
- some one else can reset the type!

IDL> print, fix_digits( [ 0.0002323,34.3434,1234000], 2)
0.00023000000 34.000000 1200000.0


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: Sat Oct 11 05:57:06 PDT 2025

Total time taken to generate the page: 0.48005 seconds