1// The -*- C++ -*- math functions header. 2// This file is part of the GNU ANSI C++ Library. 3 4#ifndef __CMATH__ 5#define __CMATH__ 6#include <_G_config.h> 7#include <math.h> 8 9#ifdef __GNUG__ 10#pragma interface "cmath" 11#endif 12 13extern "C++" { 14#if 0 15float acos (float); 16float asin (float); 17float atan (float); 18float atan2(float, float); 19float ceil (float); 20float cos (float); 21float cosh (float); 22float exp (float); 23float fabs (float); 24float floor(float); 25float fmod (float, float); 26float frexp(float, int*); 27float modf (float, float*); 28float ldexp(float, int); 29float log (float); 30float log10(float); 31float pow (float, float); 32float pow (float, int); 33float sin (float); 34float sinh (float); 35float sqrt (float); 36float tan (float); 37float tanh (float); 38#endif 39 40inline float abs (float x) { return fabs (x); } 41#if ! _G_MATH_H_INLINES /* hpux and SCO define this in math.h */ 42inline double abs (double x) { return fabs (x); } 43#endif 44 45#if 0 46double pow(double, int); 47 48long double acos (long double); 49long double asin (long double); 50long double atan (long double); 51long double atan2(long double, long double); 52long double ceil (long double); 53long double cos (long double); 54long double cosh (long double); 55long double exp (long double); 56long double fabs (long double); 57long double floor(long double); 58long double frexp(long double, int*); 59long double fmod (long double, long double); 60long double frexp(long double, int*); 61long double log (long double); 62long double log10(long double); 63long double modf (long double, long double*); 64long double pow (long double, long double); 65long double pow (long double, int); 66long double sin (long double); 67long double sinh (long double); 68long double sqrt (long double); 69long double tan (long double); 70long double tanh (long double); 71#endif 72inline long double abs (long double x) { return fabs (x); } 73 74} // extern "C++" 75 76// These are possible macros imported from C99-land. 77#undef fpclassify 78#undef isfinite 79#undef isinf 80#undef isnan 81#undef isnormal 82#undef signbit 83#undef isgreater 84#undef isgreaterequal 85#undef isless 86#undef islessequal 87#undef islessgreater 88#undef isunordered 89 90namespace std 91{ 92 inline int fpclassify(float __x) { return __fpclassifyf(__x); } 93 inline int fpclassify(double __x) { return __fpclassify(__x); } 94 inline int fpclassify(long double __x) { return __fpclassifyl(__x); } 95 96 inline bool isfinite(float __x) { return __finitef(__x); } 97 inline bool isfinite(double __x) { return __finite(__x); } 98 inline bool isfinite(long double __x) { return __finitel(__x); } 99 100 inline bool isinf(float __x) { return __isinff(__x); } 101 inline bool isinf(double __x) { return __isinf(__x); } 102 inline bool isinf(long double __x) { return __isinfl(__x); } 103 104 inline bool isnan(float __x) { return __isnanf(__x); } 105 inline bool isnan(double __x) { return __isnan(__x); } 106 inline bool isnan(long double __x) { return __isnanl(__x); } 107 108 inline bool isnormal(float __x) { return __fpclassifyf(__x) == FP_NORMAL; } 109 inline bool isnormal(double __x) { return __fpclassify(__x) == FP_NORMAL; } 110 inline bool isnormal(long double __x) { return __fpclassifyl(__x) == FP_NORMAL; } 111 112 inline bool signbit(float __x) { return __signbitf(__x); } 113 inline bool signbit(double __x) { return __signbit(__x); } 114 inline bool signbit(long double __x) { return __signbitl(__x); } 115 116#undef _wrap_expr_typeof 117 #define _wrap_expr_typeof(x, y, body) ({ \ 118 __typeof(x) X = (x); \ 119 __typeof(y) Y = (y); \ 120 return (body);}) 121 122 inline bool isgreater(float __x, float __y) { 123 _wrap_expr_typeof(__x, __y, !isnan(X) && !isnan(Y) && X > Y); 124 }; 125 inline bool isgreater(double __x, double __y) { 126 _wrap_expr_typeof(__x, __y, !isnan(X) && !isnan(Y) && X > Y); 127 }; 128 inline bool isgreater(long double __x, long double __y) { 129 _wrap_expr_typeof(__x, __y, !isnan(X) && !isnan(Y) && X > Y); 130 }; 131 132 inline bool isgreaterequal(float __x, float __y) { 133 _wrap_expr_typeof(__x, __y, !isnan(X) && !isnan(Y) && X >= Y); 134 }; 135 inline bool isgreaterequal(double __x, double __y) { 136 _wrap_expr_typeof(__x, __y, !isnan(X) && !isnan(Y) && X >= Y); 137 }; 138 inline bool isgreaterequal(long double __x, long double __y) { 139 _wrap_expr_typeof(__x, __y, !isnan(X) && !isnan(Y) && X >= Y); 140 }; 141 142 inline bool isless(float __x, float __y) { 143 _wrap_expr_typeof(__x, __y, !isnan(X) && !isnan(Y) && X < Y); 144 }; 145 inline bool isless(double __x, double __y) { 146 _wrap_expr_typeof(__x, __y, !isnan(X) && !isnan(Y) && X < Y); 147 }; 148 inline bool isless(long double __x, long double __y) { 149 _wrap_expr_typeof(__x, __y, !isnan(X) && !isnan(Y) && X < Y); 150 }; 151 152 inline bool islessequal(float __x, float __y) { 153 _wrap_expr_typeof(__x, __y, !isnan(X) && !isnan(Y) && X <= Y); 154 }; 155 inline bool islessequal(double __x, double __y) { 156 _wrap_expr_typeof(__x, __y, !isnan(X) && !isnan(Y) && X <= Y); 157 }; 158 inline bool islessequal(long double __x, long double __y) { 159 _wrap_expr_typeof(__x, __y, !isnan(X) && !isnan(Y) && X <= Y); 160 }; 161 162 inline bool islessgeater(float __x, float __y) { 163 _wrap_expr_typeof(__x, __y, X < Y || Y < X); 164 }; 165 inline bool islessgreater(double __x, double __y) { 166 _wrap_expr_typeof(__x, __y, X < Y || Y < X); 167 }; 168 inline bool islessgreater(long double __x, long double __y) { 169 _wrap_expr_typeof(__x, __y, X < Y || Y < X); 170 }; 171 172 inline bool isunordered(float __x, float __y) { 173 _wrap_expr_typeof(__x, __y, isnan(X) || isnan(Y)); 174 }; 175 inline bool isunordered(double __x, double __y) { 176 _wrap_expr_typeof(__x, __y, isnan(X) || isnan(Y)); 177 }; 178 inline bool isunordered(long double __x, long double __y) { 179 _wrap_expr_typeof(__x, __y, isnan(X) || isnan(Y)); 180 }; 181 182#undef _wrap_expr_typeof 183 184} // namespace 185 186#endif 187