EPICS Home

Experimental Physics and Industrial Control System


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

Subject: Re: using hex numbers in calc records
From: Andrew Johnson <[email protected]>
To: Martin Konrad <[email protected]>
Cc: EPICS Tech Talk <[email protected]>
Date: Thu, 17 Jun 2010 15:50:38 -0500
Hi Martin,

Martin Konrad <[email protected]> wrote:
> I'm trying to use a hex number in a calc record:
> 
> record(calc, "foo") {
> 	field(CALC, "0x01")
> 	field(INPA, "bar")
> }
> 
> This seems to work cleanly on Linux but fails on (a cross build for) Win32:
> 
> Syntax error, unknown operator/operand in CALC expression '0x01'
> Can't set "foo.CALC" to "0x01"
> Error at or before ")" in file ...
> 
> The record reference manual doesn't mention hex numbers. That's why 
> I'm unsure if I can rely on this feature. Can anyone help?

Interesting.  The CALC expression parser uses the libCom routine epicsStrtod() to convert numeric literals into double precision numbers.  We had to introduce our own version of that for Windows rather than just using the ANSI strtod() function because the Windows strtod() didn't understand the strings "Infinity" or "NaN"; we look for those strings first, but pass anything numeric to strtod() to handle.

It seems that the Linux version of strtod() accepts hex numbers, which is a C99 feature, but Windows doesn't.  If the use of hex matters enough to you, you could modify the code in base/src/libCom/misc/epicsStdlib.c to add that functionality, and I'd be happy to accept suitable a patch into base.

- Andrew


References:
using hex numbers in calc records Martin Konrad

Navigate by Date:
Prev: Re: Channel Access Writes Failed on Asyn Record Writable Fields William Lu
Next: asyn R4-14-RC1 Mark Rivers
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  <20102011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: using hex numbers in calc records Martin Konrad
Next: Channel Access Writes Failed on Asyn Record Writable Fields William Lu
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  <20102011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024