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

Home » Public Forums » archive » Floats
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: Floats [message #47944 is a reply to message #47862] Sat, 11 March 2006 04:08 Go to previous messageGo to previous message
R.Bauer is currently offline  R.Bauer
Messages: 1424
Registered: November 1998
Senior Member
Sheldon wrote:
> Hello,
>
> Here is a silly question: Can I define a float array and control how
> many decimal places are kept? For example, I want all values to only
> have an accuracy to the nearest 100th (20.15 and not 20.154983445).
> Kind of like in printing, you know, the f5.2 print definition, but only
> for variables and arrrays.
>
> Thanks,
> Sheldon
>

Hi Sheldon

we do this this way

IDL> array = RandomU(-3L, 4, 5)
IDL> print,array
0.897916 0.558249 0.766930 0.589101
0.0603181 0.973112 0.0378892 0.218058
0.142394 0.984703 0.894904 0.947651
0.804079 0.160385 0.208246 0.818130
0.103716 0.741117 0.0134482 0.0960160

IDL> array=float(string(array,format='(F7.2)'))
IDL> print,array
0.900000 0.560000 0.770000 0.590000 0.0600000
0.970000 0.0400000 0.220000
0.140000 0.980000 0.890000 0.950000 0.800000
0.160000 0.210000 0.820000
0.100000 0.740000 0.01000000 0.100000


cheers
Reimar

--
Reimar Bauer

Institut fuer Stratosphaerische Chemie (ICG-I)
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
------------------------------------------------------------ -------
a IDL library at ForschungsZentrum Juelich
http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_lib_intro. html
============================================================ =======
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: accuracy problems
Next Topic: Solaris 10 compatibility

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

Current Time: Fri Oct 17 10:49:48 PDT 2025

Total time taken to generate the page: 1.68189 seconds