EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  <20162017  2018  2019  2020  2021  2022  2023  2024  Index 1994  1995  1996  1997  1998  1999  2000  2001  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: RE: FLOOR function in EPICS CALC error
From: "Mooney, Tim M." <[email protected]>
To: "[email protected]" <[email protected]>, "[email protected]" <[email protected]>
Date: Fri, 11 Nov 2016 20:23:03 +0000
I just tried this in python, and I get the same result.
>>> math.floor((6.1-.2)/.01)
589.0

Here's why:
>>> d=((6.1-.2)/.01)
>>> print("%.18f"%d)
589.999999999999886313

Tim Mooney ([email protected]) (630)252-5417
Beamline Controls Group (www.aps.anl.gov)
Advanced Photon Source, Argonne National Lab


From: [email protected] [[email protected]] on behalf of [email protected] [[email protected]]
Sent: Friday, November 11, 2016 2:08 PM
To: [email protected]
Subject: FLOOR function in EPICS CALC error

Hi,

 

I am seeing what I think may be a rounding error in the FLOOR function and I was wondering if others had seen this. I replaced the variables in my code with actual values to reproduce the problem. I am using EPICS R3.14.12.5 with Scientific Linux 7. I also tried it with the same version of EPICS running on Linux Mint

 

In Calc records, just using an empty Calc record and putting the values in by hand:

 

record(calc,"DLY:FSTEP")

{

 field(CALC,"6.1-0.2/0.01")

}

 

 

6.1-0.2/0.01 gives 590 as it should

 

However:

FLOOR((6.1-0.2)/0.01)

 

Gives me 589

 

If I write it as follows:

FLOOR((6.1-0.2)*(1/0.01))

 

I again get 590 (as it should be)

 

I wondered if this was my install or if this has been seen before. It only seems to happen for random values.

 

Best regards,

 

Rory Clarke


References:
FLOOR function in EPICS CALC error rory.clarke

Navigate by Date:
Prev: FLOOR function in EPICS CALC error rory.clarke
Next: Re: EPICS Base Release-Candidate Double Feature! Andrew Johnson
Index: 1994  1995  1996  1997  1998  1999  2000  2001  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: FLOOR function in EPICS CALC error rory.clarke
Next: RE: FLOOR function in EPICS CALC error rory.clarke
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  <20162017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 14 Nov 2016 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·