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) {
15
return
0;
16
}
17
#if defined(fpclassify)
18
i
= fpclassify(*((
double
*) pd));
19
if
(
i
== FP_NORMAL ||
i
== FP_ZERO) {
20
return
*((
double
*) pd) >=
min
&& *((
double
*) pd) <=
max
;
21
}
else
{
22
return
0;
23
}
24
#else
25
return
*((
double
*) pd) >=
min
&& *((
double
*) pd) <=
max
;
26
#endif
27
}
28
//
nrn_isdouble
int nrn_isdouble(double *pd, double min, double max)
Definition:
isoc99.cpp:12
isoc99.h
min
#define min(a, b)
Definition:
matrix.h:157
max
#define max(a, b)
Definition:
matrix.h:154
i
#define i
Definition:
md1redef.h:12
src
oc
isoc99.cpp