1 // -*- C++ -*- C math library.
3 // Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 2, or (at your option)
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING. If not, write to the Free
18 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
21 // As a special exception, you may use this file as part of a free software
22 // library without restriction. Specifically, if other files instantiate
23 // templates or use macros or inline functions from this file, or you compile
24 // this file and link it with other files to produce an executable, this
25 // file does not by itself cause the resulting executable to be covered by
26 // the GNU General Public License. This exception does not however
27 // invalidate any other reasons why the executable file might be covered by
28 // the GNU General Public License.
31 // ISO C++ 14882: 26.5 C library
34 // Note: this is not a conforming implementation.
38 # pragma GCC system_header
39 # include_next <math.h>
40 # include_next <stdlib.h>
42 # include <bits/c++config.h>
50 #if _GLIBCPP_HAVE___BUILTIN_FABSF
51 inline float abs(float __x)
52 { return __builtin_fabsf(__x); }
53 #elif _GLIBCPP_HAVE_FABSF
54 inline float abs(float __x)
55 { return ::fabsf(__x); }
57 inline float abs(float __x)
58 { return ::fabs(static_cast<double>(__x)); }
61 #if _GLIBCPP_HAVE_ACOSF
62 inline float acos(float __x)
63 { return ::acosf(__x); }
65 inline float acos(float __x)
66 { return ::acos(static_cast<double>(__x)); }
69 #if _GLIBCPP_HAVE_ASINF
70 inline float asin(float __x)
71 { return ::asinf(__x); }
73 inline float asin(float __x)
74 { return ::asin(static_cast<double>(__x)); }
77 #if _GLIBCPP_HAVE_ATANF
78 inline float atan(float __x)
79 { return ::atanf(__x); }
81 inline float atan(float __x)
82 { return ::atan(static_cast<double>(__x)); }
85 #if _GLIBCPP_HAVE_ATAN2F
86 inline float atan2(float __y, float __x)
87 { return ::atan2f(__y, __x); }
89 inline float atan2(float __y, float __x)
90 { return ::atan2(static_cast<double>(__y), static_cast<double>(__x)); }
93 #if _GLIBCPP_HAVE_CEILF
94 inline float ceil(float __x)
95 { return ::ceilf(__x); }
97 inline float ceil(float __x)
98 { return ::ceil(static_cast<double>(__x)); }
101 #if _GLIBCPP_HAVE___BUILTIN_COSF
102 inline float cos(float __x)
103 { return __builtin_cosf(__x); }
104 #elif _GLIBCPP_HAVE_COSF
105 inline float cos(float __x)
106 { return ::cosf(__x); }
108 inline float cos(float __x)
109 { return ::cos(static_cast<double>(__x)); }
112 #if _GLIBCPP_HAVE_COSHF
113 inline float cosh(float __x)
114 { return ::coshf(__x); }
116 inline float cosh(float __x)
117 { return ::cosh(static_cast<double>(__x)); }
120 #if _GLIBCPP_HAVE_EXPF
121 inline float exp(float __x)
122 { return ::expf(__x); }
124 inline float exp(float __x)
125 { return ::exp(static_cast<double>(__x)); }
128 #if _GLIBCPP_HAVE___BUILTIN_FABSF
129 inline float fabs(float __x)
130 { return __builtin_fabsf(__x); }
131 #elif _GLIBCPP_HAVE_FABSF
132 inline float fabs(float __x)
133 { return ::fabsf(__x); }
135 inline float fabs(float __x)
136 { return ::fabs(static_cast<double>(__x)); }
139 #if _GLIBCPP_HAVE_FLOORF
140 inline float floor(float __x)
141 { return ::floorf(__x); }
143 inline float floor(float __x)
144 { return ::floor(static_cast<double>(__x)); }
147 #if _GLIBCPP_HAVE_FMODF
148 inline float fmod(float __x, float __y)
149 { return ::fmodf(__x, __y); }
151 inline float fmod(float __x, float __y)
152 { return ::fmod(static_cast<double>(__x), static_cast<double>(__y)); }
155 #if _GLIBCPP_HAVE_FREXPF
156 inline float frexp(float __x, int* __exp)
157 { return ::frexpf(__x, __exp); }
159 inline float frexp(float __x, int* __exp)
160 { return ::frexp(__x, __exp); }
163 #if _GLIBCPP_HAVE_LDEXPF
164 inline float ldexp(float __x, int __exp)
165 { return ::ldexpf(__x, __exp); }
167 inline float ldexp(float __x, int __exp)
168 { return ::ldexp(static_cast<double>(__x), __exp); }
171 #if _GLIBCPP_HAVE_LOGF
172 inline float log(float __x)
173 { return ::logf(__x); }
175 inline float log(float __x)
176 { return ::log(static_cast<double>(__x)); }
179 #if _GLIBCPP_HAVE_LOG10F
180 inline float log10(float __x)
181 { return ::log10f(__x); }
183 inline float log10(float __x)
184 { return ::log10(static_cast<double>(__x)); }
187 #if _GLIBCPP_HAVE_MODFF
188 inline float modf(float __x, float* __iptr)
189 { return ::modff(__x, __iptr); }
191 inline float modf(float __x, float* __iptr)
194 double __res = ::modf(static_cast<double>(__x), &__tmp);
195 *__iptr = static_cast<float> (__tmp);
200 #if _GLIBCPP_HAVE_POWF
201 inline float pow(float __x, float __y)
202 { return ::powf(__x, __y); }
204 inline float pow(float __x, float __y)
205 { return ::pow(static_cast<double>(__x), static_cast<double>(__y)); }
208 float pow(float, int);
210 #if _GLIBCPP_HAVE___BUILTIN_SINF
211 inline float sin(float __x)
212 { return __builtin_sinf(__x); }
213 #elif _GLIBCPP_HAVE_SINF
214 inline float sin(float __x)
215 { return ::sinf(__x); }
217 inline float sin(float __x)
218 { return ::sin(static_cast<double>(__x)); }
221 #if _GLIBCPP_HAVE_SINHF
222 inline float sinh(float __x)
223 { return ::sinhf(__x); }
225 inline float sinh(float __x)
226 { return ::sinh(static_cast<double>(__x)); }
229 #if _GLIBCPP_HAVE___BUILTIN_SQRTF
230 inline float sqrt(float __x)
231 { return __builtin_sqrtf(__x); }
232 #elif _GLIBCPP_HAVE_SQRTF
233 inline float sqrt(float __x)
234 { return ::sqrtf(__x); }
236 inline float sqrt(float __x)
237 { return ::sqrt(static_cast<double>(__x)); }
240 #if _GLIBCPP_HAVE_TANF
241 inline float tan(float __x)
242 { return ::tanf(__x); }
244 inline float tan(float __x)
245 { return ::tan(static_cast<double>(__x)); }
248 #if _GLIBCPP_HAVE_TANHF
249 inline float tanh(float __x)
250 { return ::tanhf(__x); }
252 inline float tanh(float __x)
253 { return ::tanh(static_cast<double>(__x)); }
260 #if _GLIBCPP_HAVE___BUILTIN_FABS
261 inline double abs(double __x)
262 { return __builtin_fabs(__x); }
264 inline double abs(double __x)
265 { return ::fabs(__x); }
268 inline double acos(double __x)
269 { return ::acos(__x); }
271 inline double asin(double __x)
272 { return ::asin(__x); }
274 inline double atan(double __x)
275 { return ::atan(__x); }
277 inline double atan2(double __y, double __x)
278 { return ::atan2(__y, __x); }
280 inline double ceil(double __x)
281 { return ::ceil(__x); }
283 #if _GLIBCPP_HAVE___BUILTIN_COS
284 inline double cos(double __x)
285 { return __builtin_cos(__x); }
287 inline double cos(double __x)
288 { return ::cos(__x); }
291 inline double cosh(double __x)
292 { return ::cosh(__x); }
294 inline double exp(double __x)
295 { return ::exp(__x); }
298 #if _GLIBCPP_HAVE___BUILTIN_FABS
299 inline double fabs(double __x)
300 { return __builtin_fabs(__x); }
302 inline double fabs(double __x)
303 { return ::fabs(__x); }
306 inline double floor(double __x)
307 { return ::floor(__x); }
309 inline double fmod(double __x, double __y)
310 { return ::fmod(__x, __y); }
312 inline double frexp(double __x, int* __exp)
313 { return ::frexp(__x, __exp); }
315 inline double ldexp(double __x, int __exp)
316 { return ::ldexp(__x, __exp); }
318 inline double log(double __x)
319 { return ::log(__x); }
321 inline double log10(double __x)
322 { return ::log10(__x); }
324 inline double modf(double __x, double* __iptr)
325 { return ::modf(__x, __iptr); }
327 inline double pow(double __x, double __y)
328 { return ::pow(__x, __y); }
330 double pow (double, int);
332 #if _GLIBCPP_HAVE___BUILTIN_SIN
333 inline double sin(double __x)
334 { return __builtin_sin(__x); }
336 inline double sin(double __x)
337 { return ::sin(__x); }
340 inline double sinh(double __x)
341 { return ::sinh(__x); }
343 #if _GLIBCPP_HAVE___BUILTIN_SQRT
344 inline double sqrt(double __x)
345 { return __builtin_fsqrt(__x); }
347 inline double sqrt(double __x)
348 { return ::sqrt(__x); }
351 inline double tan(double __x)
352 { return ::tan(__x); }
354 inline double tanh(double __x)
355 { return ::tanh(__x); }
360 #if _GLIBCPP_HAVE___BUILTIN_FABSL
361 inline long double abs(long double __x)
362 { return __builtin_fabsl(__x); }
363 #elif _GLIBCPP_HAVE_FABSL
364 inline long double abs(long double __x)
365 { return ::fabsl(__x); }
368 #if _GLIBCPP_HAVE_ACOSL
369 inline long double acos(long double __x)
370 { return ::acosl(__x); }
373 #if _GLIBCPP_HAVE_ASINL
374 inline long double asin(long double __x)
375 { return ::asinl(__x); }
378 #if _GLIBCPP_HAVE_ATANL
379 inline long double atan(long double __x)
380 { return ::atanl(__x); }
383 #if _GLIBCPP_HAVE_ATAN2L
384 inline long double atan2(long double __y, long double __x)
385 { return ::atan2l(__y, __x); }
388 #if _GLIBCPP_HAVE_CEILL
389 inline long double ceil(long double __x)
390 { return ::ceill(__x); }
393 #if _GLIBCPP_HAVE___BUILTIN_COSL
394 inline long double cos(long double __x)
395 { return __builtin_cosl(__x); }
396 #elif _GLIBCPP_HAVE_COSL
397 inline long double cos(long double __x)
398 { return ::cosl(__x); }
401 #if _GLIBCPP_HAVE_COSHL
402 inline long double cosh(long double __x)
403 { return ::coshl(__x); }
406 #if _GLIBCPP_HAVE_EXPL
407 inline long double exp(long double __x)
408 { return ::expl(__x); }
411 #if _GLIBCPP_HAVE___BUILTIN_FABSL
412 inline long double fabs(long double __x)
413 { return __builtin_fabsl(__x); }
414 #elif _GLIBCPP_HAVE_FABSL
415 inline long double fabs(long double __x)
416 { return ::fabsl(__x); }
419 #if _GLIBCPP_HAVE_FLOORL
420 inline long double floor(long double __x)
421 { return ::floorl(__x); }
424 #if _GLIBCPP_HAVE_FMODL
425 inline long double fmod(long double __x, long double __y)
426 { return ::fmodl(__x, __y); }
429 #if _GLIBCPP_HAVE_FREXPL
430 inline long double frexp(long double __x, int* __exp)
431 { return ::frexpl(__x, __exp); }
434 #if _GLIBCPP_HAVE_LDEXPL
435 inline long double ldexp(long double __x, int __exp)
436 { return ::ldexpl(__x, __exp); }
439 #if _GLIBCPP_HAVE_LOGL
440 inline long double log(long double __x)
441 { return ::logl(__x); }
444 #if _GLIBCPP_HAVE_LOG10L
445 inline long double log10(long double __x)
446 { return ::log10l(__x); }
449 #if _GLIBCPP_HAVE_MODFL
450 inline long double modf(long double __x, long double* __iptr)
451 { return ::modfl(__x, __iptr); }
454 #if _GLIBCPP_HAVE_POWL
455 inline long double pow(long double __x, long double __y)
456 { return ::powl(__x, __y); }
459 long double pow(long double, int);
461 #if _GLIBCPP_HAVE___BUILTIN_SINL
462 inline long double sin(long double __x)
463 { return __builtin_sinl(__x); }
464 #elif _GLIBCPP_HAVE_SINL
465 inline long double sin(long double __x)
466 { return ::sinl(__x); }
469 #if _GLIBCPP_HAVE_SINHL
470 inline long double sinh(long double __x)
471 { return ::sinhl(__x); }
474 #if _GLIBCPP_HAVE___BUILTIN_SQRTL
475 inline long double sqrt(long double __x)
476 { return __builtin_sqrtl(__x); }
477 #elif _GLIBCPP_HAVE_SQRTL
478 inline long double sqrt(long double __x)
479 { return ::sqrtl(__x); }
482 #if _GLIBCPP_HAVE_TANL
483 inline long double tan(long double __x)
484 { return ::tanl(__x); }
487 #if _GLIBCPP_HAVE_TANHL
488 inline long double tanh(long double __x)
489 { return ::tanhl(__x); }