EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  <20042005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  <20042005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: PREC
From: Eric Norum <[email protected]>
To: Dirk Zimoch <[email protected]>
Cc: TECHTALK <[email protected]>
Date: Fri, 11 Jun 2004 09:14:14 -0500
Dirk Zimoch wrote:
Hi all,

we all know the PREC field of many records. Unforunately, its purpose is not documented very precisely. The Application Developer's Guide says in chapter 3.5.1 (EPICS Overview - Channel Access - Client Services):

"In addition to requesting process variable values, any combination of the following additional information may be requested:
[...]
* Precision: Precision with which to display floating point numbers."


In the Record Reference Manual, one can read e.g. in the ai chapter:

"The PREC field determines the floating point precision with which to display VAL."

But what does this exactly mean? I think, the most intuitive sense is to format the value like "%.<PREC>f". At least this is the default behaviour of medm when using a text monitor. But why not like "%.<PREC>g" or "%.<PREC>e"? And why does neither caget nor camonitor honor PREC? And what about negative PREC values?

I'm not sure that the most intuitive sense is "%.<PREC>f". I interpret the documentation to mean that PREC should result in "%.<PREC>g".



I suggest the following: PREC >= 0 means to format the value like printf("%.*f",PREC,VAL); PREC < 0 means to format the value like printf("%.*e",-PREC,VAL);


I worry that there are a lot of tools out there that might not take well to negative PREC values.


All tools including caget and camonitor should honor PREC.

Any comments?

I'd argue that PREC should specify the number of significant digits and that the style (f/e) should be chosen according to the printf rules:


           If the precision is missing, 6 digits are given; if the
           precision is zero, it is treated as 1.  Style e is used if the
           exponent from its conversion is less than -4 or greater than or
           equal to the precision.  Trailing zeros are removed from the
           fractional part of the result; a decimal point appears only if it
           is followed by at least one digit.

With PREC=2, pi would print as 3.1, pi/100 as 0.031, pi/10000 as 0.00031, pi/100000 as 3.1e-5, pi*10 as 31 and pi*100 as 3.1e2.


-- Eric Norum [email protected] Advanced Photon Source Phone: (630) 252-4793 Argonne National Laboratory


Replies:
Re: PREC Dirk Zimoch
References:
PREC Dirk Zimoch

Navigate by Date:
Prev: Re: PREC Ralph Lange
Next: JCA maintainers John Maclean
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  <20042005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: PREC Marty Kraimer
Next: Re: PREC Dirk Zimoch
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  <20042005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 10 Aug 2010 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·