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

Home » Public Forums » archive » Re: the precision of PRINT and HELP statements
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: the precision of PRINT and HELP statements [message #26928] Thu, 04 October 2001 10:24
Paul van Delst is currently offline  Paul van Delst
Messages: 364
Registered: March 1997
Senior Member
George McCabe wrote:
>
> hello,
>
> this one made me laugh when i realized what was going on -
>
> IDL> help, chkN
> CHKN LONG = 140486
> IDL> help, float(Nhb)/Nreq0
> <Expression> FLOAT = 140486.
> IDL> print, chkN - float(Nhb)/Nreq0
> -0.500000
>
> perhaps one should expect IDL's PRINT statement to act this way,
>
> IDL> print, float(Nhb)/Nreq0
> 140486.
> IDL> print, format='(g)', float(Nhb)/Nreq0
> 140486.5
>
> but, the HELP command i feel should show the actual value to the
> precision of the variable type.

Hmm. My personal opinion is that if you need to know the actual value of a variable to its
precision (e.g. X number of significant digits, or 6 decimal places, or something else) then it
is encumbent upon the programmer to tell exactly what he/she wants printed/displayed. Relying
on default behaviour is means you don't care what the output format is. Why use HELP to print
out number values when you know a PRINT, FORMAT=..etc.. will give you what you want? And the
online help states for the expression arguments to HELP:

HELP
Expression(s)
The arguments are interpreted differently depending on the keyword selected. If no keyword is
selected, HELP displays basic information for its parameters. For example, to see the type and
structure of the variable A, enter:
HELP, A

The important phrase being "basic information."

I actually find the truncation that occurs in cases like the one that you mention helpful as it
has taught me to be careful when printing out numbers for inspection. The same applies in my
Fortran code too.

paulv

--
Paul van Delst Religious and cultural
CIMSS @ NOAA/NCEP purity is a fundamentalist
Ph: (301)763-8000 x7274 fantasy
Fax:(301)763-8545 V.S.Naipaul
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: catching command line arguments from the shell
Next Topic: Re: findfile on unix bug - help

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

Current Time: Wed Oct 08 15:26:37 PDT 2025

Total time taken to generate the page: 0.00542 seconds