NEURON
isoc99.cpp
Go to the documentation of this file.
1 #define _ISOC99_SOURCE
2 #include <cmath>
3 #include <cstdlib>
4 #include "isoc99.h"
5 /* trying to safely determine if a pointer is a pointer to a double where the
6 double value would be in a specific range without causing floating exceptions
7 Of course this founders in general on the dereferencing of invalid memory
8 so it can only be used when pd is valid over sizeof(double).
9 */
10 
11 
12 extern "C" int nrn_isdouble(double *pd, double min, double max) {
13  int i;
14  if (!pd) { return 0; }
15 #if defined(fpclassify)
16  i = fpclassify(*((double*)pd));
17  if (i == FP_NORMAL || i == FP_ZERO) {
18  return *((double*)pd) >= min && *((double*)pd) <= max;
19  }else{
20  return 0;
21  }
22 #else
23  return *((double *) pd) >= min && *((double *) pd) <= max;
24 #endif
25 }
26 //
double max(double a, double b)
Definition: geometry3d.cpp:22
#define min(a, b)
Definition: matrix.h:157
int nrn_isdouble(double *pd, double min, double max)
Definition: isoc99.cpp:12
#define i
Definition: md1redef.h:12