mirror of
https://github.com/Unidata/netcdf-c.git
synced 2025-03-01 17:06:03 +08:00
Define isnan and isinf for OSX
This commit is contained in:
parent
70c873cd91
commit
931f6d0ad4
@ -25,7 +25,10 @@
|
||||
#ifndef INFINITYF
|
||||
#define INFINITYF ((float)INFINITY)
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
extern int isinf(double x);
|
||||
extern int isnan(double x);
|
||||
#else
|
||||
#if ! (defined(isinf) || HAVE_DECL_ISINF)
|
||||
#define isinf(x) (DBL_MAX/((double)(x))==0.0)
|
||||
#endif /* !HAVE_DECL_ISINF */
|
||||
@ -35,5 +38,6 @@
|
||||
#if ! (defined(isfinite) || HAVE_DECL_ISFINITE)
|
||||
#define isfinite(x) (!(isinf(x)||isnan(x)))
|
||||
#endif /* !HAVE_DECL_ISFINITE */
|
||||
#endif /*!APPLE*/
|
||||
|
||||
#endif /* _ISNAN_H */
|
||||
|
@ -351,3 +351,22 @@ done:
|
||||
nclistfreeall(modelist);
|
||||
return found;
|
||||
}
|
||||
|
||||
#ifdef __APPLE__
|
||||
int isinf(double x)
|
||||
{
|
||||
union { unsigned long long u; double f; } ieee754;
|
||||
ieee754.f = x;
|
||||
return ( (unsigned)(ieee754.u >> 32) & 0x7fffffff ) == 0x7ff00000 &&
|
||||
( (unsigned)ieee754.u == 0 );
|
||||
}
|
||||
|
||||
int isnan(double x)
|
||||
{
|
||||
union { unsigned long long u; double f; } ieee754;
|
||||
ieee754.f = x;
|
||||
return ( (unsigned)(ieee754.u >> 32) & 0x7fffffff ) +
|
||||
( (unsigned)ieee754.u != 0 ) > 0x7ff00000;
|
||||
}
|
||||
|
||||
#endif /*APPLE*/
|
||||
|
Loading…
Reference in New Issue
Block a user