EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  <20162017  2018  2019  2020  2021  2022  2023  2024  Index 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  <20162017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: ABS() in calc record
From: "Laznovsky Michael (PSI)" <[email protected]>
To: "[email protected]" <[email protected]>, "[email protected]" <[email protected]>
Date: Sat, 21 May 2016 10:43:54 +0000
Hello- to the keepers of the Sacred Source Code, in the course of developing some
displays I noticed that a PV which should never be < 0 had a persistent flickering minus
sign (-0.000)... the cause was traced to the implentation of ABS in the calc record, ie:
 
        case ABS_VAL:
            if (*ptop < 0.0) *ptop = - *ptop;
            break;
 
In my case, the CALC is "ABS(A*B)", and e.g. A=0 and B<0 results in ABS(-0), which does
not satisfy the if() in the code because -0 is NOT less than zero, so the sign is not flipped
back to positive.
 
Using fabs() instead fixes it (and probably also saves a branch).
 
cheers,
Mike
 
-----
 
 
 

Replies:
RE: ABS() in calc record Laznovsky Michael (PSI)

Navigate by Date:
Prev: Base 3.15.4-rc1 available Ralph Lange
Next: RE: ABS() in calc record Laznovsky Michael (PSI)
Index: 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  <20162017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Base 3.15.4-rc1 available Ralph Lange
Next: RE: ABS() in calc record Laznovsky Michael (PSI)
Index: 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  <20162017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 21 May 2016 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·