Mercurial > hg > qm-dsp
comparison maths/nan-inf.h @ 92:c313a173f4a9
* Sort out this isnan/isinf nonsense once and for all
author | Chris Cannam |
---|---|
date | Wed, 09 Feb 2011 15:25:36 +0000 |
parents | 054c384d860d |
children | 701233f8ed41 |
comparison
equal
deleted
inserted
replaced
91:6eb4c658c799 | 92:c313a173f4a9 |
---|---|
1 | 1 |
2 #ifndef NAN_INF_H | 2 #ifndef NAN_INF_H |
3 #define NAN_INF_H | 3 #define NAN_INF_H |
4 | 4 |
5 #include <math.h> | 5 #define ISNAN(x) (sizeof(x) == sizeof(double) ? ISNANd(x) : ISNANf(x)) |
6 | 6 static inline int ISNANf(float x) { return x != x; } |
7 #ifdef sun | 7 static inline int ISNANd(double x) { return x != x; } |
8 | 8 |
9 #include <ieeefp.h> | 9 #define ISINF(x) (sizeof(x) == sizeof(double) ? ISINFd(x) : ISINFf(x)) |
10 #define ISNAN(x) ((sizeof(x)==sizeof(float))?isnanf(x):isnand(x)) | 10 static inline int ISINFf(float x) { return !ISNANf(x) && ISNANf(x - x); } |
11 #define ISINF(x) (!finite(x)) | 11 static inline int ISINFd(double x) { return !ISNANd(x) && ISNANd(x - x); } |
12 | |
13 #else | |
14 | |
15 #define ISNAN(x) isnan(x) | |
16 #define ISINF(x) isinf(x) | |
17 | 12 |
18 #endif | 13 #endif |
19 | |
20 #endif |