Experimental Physics and Industrial Control System
|
IOC database access converts DBF_FLOAT to DBR_STRING by calling
cvtFloatToString.
Similarly DBF_DOUBLE is converted to DBR_STRING by calling
cvtDoubleToString.
Both accept precision as an argument.
In 3.14 they are in <base>/src/libCom/cvtFast/cvtFast.c
For moderate size values precision means number of decimal places. See
the code for how it handles large numbers or precision > 8.
Early versions of vxWorks had a very slow implementation of %g format
conversion. It could only do about 100 conversions per second on a
68020. Thus cvtFast.c was created.
Note that cvtFast has a number of usefull converrsion routines:
cvtFloatToString(float value, char *pstring, unsigned short
precision);
cvtDoubleToString(double value, char *pstring, unsigned short
precision);
cvtFloatToExpString(float value, char *pstring, unsigned short
precision);
cvtDoubleToExpString(double value, char *pstring, unsigned short
precision);
cvtFloatToCompactString(float value, char *pstring, unsigned
short precision);
cvtDoubleToCompactString(double value, char *pstring, unsigned
short precision);
cvtCharToString(signed char value, char *pstring);
cvtUcharToString(unsigned char value, char *pstring);
cvtShortToString(short value, char *pstring);
cvtUshortToString(unsigned short value, char *pstring);
cvtLongToString(epicsInt32 value, char *pstring);
cvtUlongToString(epicsUInt32 value, char *pstring);
cvtLongToHexString(epicsInt32 value, char *pstring);
cvtLongToOctalString(epicsInt32 value, char *pstring);
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 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);
All tools including caget and camonitor should honor PREC.
Any comments?
Dirk
- References:
- PREC Dirk Zimoch
- Navigate by Date:
- Prev:
Re: PREC Dirk Zimoch
- Next:
Re: PREC Ralph Lange
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
<2004>
2005
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 Ralph Lange
- Next:
Re: PREC Eric Norum
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
<2004>
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
|
ANJ, 10 Aug 2010 |
·
Home
·
News
·
About
·
Base
·
Modules
·
Extensions
·
Distributions
·
Download
·
·
Search
·
EPICS V4
·
IRMIS
·
Talk
·
Bugs
·
Documents
·
Links
·
Licensing
·
|