diff options
author | Rich Felker <dalias@aerifal.cx> | 2011-06-08 16:33:04 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2011-06-08 16:33:04 -0400 |
commit | e0037efc1253e190c7c75f74e5a05333fdd807bb (patch) | |
tree | 1c5f1a4a5ae9c963be046a3c147423d1b5c3c21c /include | |
parent | e1d2a8e2394640e4b573117b7653fd0f163671fe (diff) | |
download | musl-e0037efc1253e190c7c75f74e5a05333fdd807bb.tar.gz |
isgreater etc. relation macros for math.h
Diffstat (limited to 'include')
-rw-r--r-- | include/math.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/include/math.h b/include/math.h index fffdf4f7..67724828 100644 --- a/include/math.h +++ b/include/math.h @@ -44,6 +44,24 @@ int __fpclassifyl(long double); #define isnormal(x) (fpclassify(x) == FP_NORMAL) #define isfinite(x) (fpclassify(x) > FP_INFINITE) +#define isunordered(x,y) (isnan((x)) ? ((y),1) : isnan((y))) + +static inline int __isrel(long double __x, long double __y, int __rel) +{ + if (isunordered(__x, __y)) return 0; + if (__rel==-2) return __x < __y; + if (__rel==2) return __x > __y; + if (__rel==-1) return __x <= __y; + if (__rel==1) return __x >= __y; + return __x != __y; +} + +#define isless(x,y) __isrel((x), (y), -2) +#define islessequal(x,y) __isrel((x), (y), -1) +#define islessgreater(x,y) __isrel((x), (y), 0) +#define isgreaterequal(x,y) __isrel((x), (y), 1) +#define isgreater(x,y) __isrel((x), (y), 2) + double acos(double); float acosf(float); long double acosl(long double); |