Experimental Physics and Industrial Control System
Recently Timo Korhonen mentioned a problem caused by the calcoutRecord passing
on a NaN value to other records. Recently we saw something that we suspect was
caused by something generating either a NAN or an INF. The latest 3.13 known
problems describes a fix for the calcOutRecord (and calcPerform) that fixes the
NAN problem. We are still not handling the INF problem.
Let me first give a brief discussion of NAN and INF. The IEEE floating point
standard defines the concept of NAN (not a number) and INF (infinity). For each
the exponent portion of the number has a unique bit pattern (normally all 1s), A
NAN has a nonzero significand and an INF has a zero significand. A NAN is
generated for invalid operations like 0/0. An INF is generated for exponent
overflow.
Part of the solution to the NAN problem Timo discovered was to make the
following change to calcPerform
diff -r1.31.6.1 calcPerform.c
104a105,106
> #include <private/mathP.h> /* For isNan*/
> #define isnan isNan
517c519
< return(0);
---
> return((isnan(*presult) ? -1 : 0));
Thus a error is returned in calcPerform calculates a NAN. It looks like a
solution for both NAN and INF is to change the return to
return(((isnan(*presult)||isinf(*presult)) ? -1 : 0));
PROBLEM:
This assumes that isnan and isinf are provided on all platforms that epics supports.
Both isnan and isinf are defined as part of the ISO C standard from 1999.
They are supported on redhat 7.2 linux. They are not supported on vxWorks 5.4 or
on solaris 8. Not suprising considering the 1999 date.
The following are diffs that allow me to compile 3.13 calcPerform on solaris,
vxWorks, and linux redhat 7.2
> #include <stddef.h>
119a115,128
> #ifdef vxWorks
> #include <vxWorks.h>
> #include <private/mathP.h> /* For isNan*/
> #define isnan isNan
> #define isinf isInf
> #endif
>
> #ifdef SOLARIS
> #define __EXTENSIONS__
> #include <limits.h>
> #define isinf(D) \
> ((fabs((D))>DBL_MAX || fabs((D))<DBL_MIN) ? 1 : 0)
> #endif
>
519c528
< return(0);
---
> return(((isnan(*presult)||isinf(*presult)) ? -1 : 0));
This is REALLY ugly. Worse what about HPUX, WINxx, and earlier releases of
Solaris and Linux?
What to do??????
Marty Kraimer
- Replies:
- RE: NAN and INF Jeff Hill
- Navigate by Date:
- Prev:
RE: ca_test bus error on solaris-sparc-gnu + fix Jeff Hill
- Next:
RE: NAN and INF Jeff Hill
- 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: waveform record question Marty Kraimer
- Next:
RE: NAN and INF Jeff Hill
- 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