1 /* Prototype declarations for math functions; helper file for <math.h>.
2 Copyright (C) 1996-2017 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
19 /* NOTE: Because of the special way this file is used by <math.h>, this
20 file must NOT be protected from multiple inclusion as header files
23 This file provides prototype declarations for the math functions.
24 Most functions are declared using the macro:
26 __MATHCALL (NAME,[_r], (ARGS...));
28 This means there is a function `NAME' returning `double' and a function
29 `NAMEf' returning `float'. Each place `_Mdouble_' appears in the
30 prototype, that is actually `double' in the prototype for `NAME' and
31 `float' in the prototype for `NAMEf'. Reentrant variant functions are
32 called `NAME_r' and `NAMEf_r'.
34 Functions returning other types like `int' are declared using the macro:
36 __MATHDECL (TYPE, NAME,[_r], (ARGS...));
38 This is just like __MATHCALL but for a function returning `TYPE'
39 instead of `_Mdouble_'. In all of these cases, there is still
40 both a `NAME' and a `NAMEf' that takes `float' arguments.
42 Note that there must be no whitespace before the argument passed for
43 NAME, to make token pasting work with -traditional. */
46 # error "Never include <bits/mathcalls.h> directly; include <math.h> instead."
50 /* Trigonometric functions. */
52 _Mdouble_BEGIN_NAMESPACE
53 /* Arc cosine of X. */
54 __MATHCALL (acos
,, (_Mdouble_ __x
));
56 __MATHCALL (asin
,, (_Mdouble_ __x
));
57 /* Arc tangent of X. */
58 __MATHCALL (atan
,, (_Mdouble_ __x
));
59 /* Arc tangent of Y/X. */
60 __MATHCALL (atan2
,, (_Mdouble_ __y
, _Mdouble_ __x
));
63 __MATHCALL_VEC (cos
,, (_Mdouble_ __x
));
65 __MATHCALL_VEC (sin
,, (_Mdouble_ __x
));
67 __MATHCALL (tan
,, (_Mdouble_ __x
));
69 /* Hyperbolic functions. */
71 /* Hyperbolic cosine of X. */
72 __MATHCALL (cosh
,, (_Mdouble_ __x
));
73 /* Hyperbolic sine of X. */
74 __MATHCALL (sinh
,, (_Mdouble_ __x
));
75 /* Hyperbolic tangent of X. */
76 __MATHCALL (tanh
,, (_Mdouble_ __x
));
77 _Mdouble_END_NAMESPACE
80 /* Cosine and sine of X. */
81 __MATHDECL_VEC (void,sincos
,,
82 (_Mdouble_ __x
, _Mdouble_
*__sinx
, _Mdouble_
*__cosx
));
85 #if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
87 /* Hyperbolic arc cosine of X. */
88 __MATHCALL (acosh
,, (_Mdouble_ __x
));
89 /* Hyperbolic arc sine of X. */
90 __MATHCALL (asinh
,, (_Mdouble_ __x
));
91 /* Hyperbolic arc tangent of X. */
92 __MATHCALL (atanh
,, (_Mdouble_ __x
));
96 /* Exponential and logarithmic functions. */
98 _Mdouble_BEGIN_NAMESPACE
99 /* Exponential function of X. */
100 __MATHCALL_VEC (exp
,, (_Mdouble_ __x
));
102 /* Break VALUE into a normalized fraction and an integral power of 2. */
103 __MATHCALL (frexp
,, (_Mdouble_ __x
, int *__exponent
));
105 /* X times (two to the EXP power). */
106 __MATHCALL (ldexp
,, (_Mdouble_ __x
, int __exponent
));
108 /* Natural logarithm of X. */
109 __MATHCALL_VEC (log
,, (_Mdouble_ __x
));
111 /* Base-ten logarithm of X. */
112 __MATHCALL (log10
,, (_Mdouble_ __x
));
114 /* Break VALUE into integral and fractional parts. */
115 __MATHCALL (modf
,, (_Mdouble_ __x
, _Mdouble_
*__iptr
)) __nonnull ((2));
116 _Mdouble_END_NAMESPACE
118 #if __GLIBC_USE (IEC_60559_FUNCS_EXT)
119 /* Compute exponent to base ten. */
120 __MATHCALL (exp10
,, (_Mdouble_ __x
));
123 /* Another name occasionally used. */
124 __MATHCALL (pow10
,, (_Mdouble_ __x
));
127 #if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
128 __BEGIN_NAMESPACE_C99
129 /* Return exp(X) - 1. */
130 __MATHCALL (expm1
,, (_Mdouble_ __x
));
132 /* Return log(1 + X). */
133 __MATHCALL (log1p
,, (_Mdouble_ __x
));
135 /* Return the base 2 signed integral exponent of X. */
136 __MATHCALL (logb
,, (_Mdouble_ __x
));
141 __BEGIN_NAMESPACE_C99
142 /* Compute base-2 exponential of X. */
143 __MATHCALL (exp2
,, (_Mdouble_ __x
));
145 /* Compute base-2 logarithm of X. */
146 __MATHCALL (log2
,, (_Mdouble_ __x
));
151 /* Power functions. */
153 _Mdouble_BEGIN_NAMESPACE
154 /* Return X to the Y power. */
155 __MATHCALL_VEC (pow
,, (_Mdouble_ __x
, _Mdouble_ __y
));
157 /* Return the square root of X. */
158 __MATHCALL (sqrt
,, (_Mdouble_ __x
));
159 _Mdouble_END_NAMESPACE
161 #if defined __USE_XOPEN || defined __USE_ISOC99
162 __BEGIN_NAMESPACE_C99
163 /* Return `sqrt(X*X + Y*Y)'. */
164 __MATHCALL (hypot
,, (_Mdouble_ __x
, _Mdouble_ __y
));
168 #if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
169 __BEGIN_NAMESPACE_C99
170 /* Return the cube root of X. */
171 __MATHCALL (cbrt
,, (_Mdouble_ __x
));
176 /* Nearest integer, absolute value, and remainder functions. */
178 _Mdouble_BEGIN_NAMESPACE
179 /* Smallest integral value not less than X. */
180 __MATHCALLX (ceil
,, (_Mdouble_ __x
), (__const__
));
182 /* Absolute value of X. */
183 __MATHCALLX (fabs
,, (_Mdouble_ __x
), (__const__
));
185 /* Largest integer not greater than X. */
186 __MATHCALLX (floor
,, (_Mdouble_ __x
), (__const__
));
188 /* Floating-point modulo remainder of X/Y. */
189 __MATHCALL (fmod
,, (_Mdouble_ __x
, _Mdouble_ __y
));
192 /* Return 0 if VALUE is finite or NaN, +1 if it
193 is +Infinity, -1 if it is -Infinity. */
194 __MATHDECL_1 (int,__isinf
,, (_Mdouble_ __value
)) __attribute__ ((__const__
));
196 /* Return nonzero if VALUE is finite and not NaN. */
197 __MATHDECL_1 (int,__finite
,, (_Mdouble_ __value
)) __attribute__ ((__const__
));
198 _Mdouble_END_NAMESPACE
201 # if (!defined __cplusplus \
202 || __cplusplus < 201103L /* isinf conflicts with C++11. */ \
203 || __MATH_DECLARING_DOUBLE == 0) /* isinff or isinfl don't. */
204 /* Return 0 if VALUE is finite or NaN, +1 if it
205 is +Infinity, -1 if it is -Infinity. */
206 __MATHDECL_1 (int,isinf
,, (_Mdouble_ __value
)) __attribute__ ((__const__
));
209 /* Return nonzero if VALUE is finite and not NaN. */
210 __MATHDECL_1 (int,finite
,, (_Mdouble_ __value
)) __attribute__ ((__const__
));
212 /* Return the remainder of X/Y. */
213 __MATHCALL (drem
,, (_Mdouble_ __x
, _Mdouble_ __y
));
216 /* Return the fractional part of X after dividing out `ilogb (X)'. */
217 __MATHCALL (significand
,, (_Mdouble_ __x
));
218 #endif /* Use misc. */
221 __BEGIN_NAMESPACE_C99
222 /* Return X with its signed changed to Y's. */
223 __MATHCALLX (copysign
,, (_Mdouble_ __x
, _Mdouble_ __y
), (__const__
));
228 __BEGIN_NAMESPACE_C99
229 /* Return representation of qNaN for double type. */
230 __MATHCALLX (nan
,, (const char *__tagb
), (__const__
));
235 /* Return nonzero if VALUE is not a number. */
236 __MATHDECL_1 (int,__isnan
,, (_Mdouble_ __value
)) __attribute__ ((__const__
));
238 #if defined __USE_MISC || (defined __USE_XOPEN && !defined __USE_XOPEN2K)
239 # if (!defined __cplusplus \
240 || __cplusplus < 201103L /* isnan conflicts with C++11. */ \
241 || __MATH_DECLARING_DOUBLE == 0) /* isnanf or isnanl don't. */
242 /* Return nonzero if VALUE is not a number. */
243 __MATHDECL_1 (int,isnan
,, (_Mdouble_ __value
)) __attribute__ ((__const__
));
247 #if defined __USE_MISC || (defined __USE_XOPEN && __MATH_DECLARING_DOUBLE)
248 /* Bessel functions. */
249 __MATHCALL (j0
,, (_Mdouble_
));
250 __MATHCALL (j1
,, (_Mdouble_
));
251 __MATHCALL (jn
,, (int, _Mdouble_
));
252 __MATHCALL (y0
,, (_Mdouble_
));
253 __MATHCALL (y1
,, (_Mdouble_
));
254 __MATHCALL (yn
,, (int, _Mdouble_
));
258 #if defined __USE_XOPEN || defined __USE_ISOC99
259 __BEGIN_NAMESPACE_C99
260 /* Error and gamma functions. */
261 __MATHCALL (erf
,, (_Mdouble_
));
262 __MATHCALL (erfc
,, (_Mdouble_
));
263 __MATHCALL (lgamma
,, (_Mdouble_
));
268 __BEGIN_NAMESPACE_C99
269 /* True gamma function. */
270 __MATHCALL (tgamma
,, (_Mdouble_
));
274 #if defined __USE_MISC || (defined __USE_XOPEN && !defined __USE_XOPEN2K)
275 /* Obsolete alias for `lgamma'. */
276 __MATHCALL (gamma
,, (_Mdouble_
));
280 /* Reentrant version of lgamma. This function uses the global variable
281 `signgam'. The reentrant version instead takes a pointer and stores
282 the value through it. */
283 __MATHCALL (lgamma
,_r
, (_Mdouble_
, int *__signgamp
));
287 #if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
288 __BEGIN_NAMESPACE_C99
289 /* Return the integer nearest X in the direction of the
290 prevailing rounding mode. */
291 __MATHCALL (rint
,, (_Mdouble_ __x
));
293 /* Return X + epsilon if X < Y, X - epsilon if X > Y. */
294 __MATHCALLX (nextafter
,, (_Mdouble_ __x
, _Mdouble_ __y
), (__const__
));
295 # if defined __USE_ISOC99 && !defined __LDBL_COMPAT
296 __MATHCALLX (nexttoward
,, (_Mdouble_ __x
, long double __y
), (__const__
));
299 #if __GLIBC_USE (IEC_60559_BFP_EXT)
300 /* Return X - epsilon. */
301 __MATHCALL (nextdown
,, (_Mdouble_ __x
));
302 /* Return X + epsilon. */
303 __MATHCALL (nextup
,, (_Mdouble_ __x
));
306 /* Return the remainder of integer divison X / Y with infinite precision. */
307 __MATHCALL (remainder
,, (_Mdouble_ __x
, _Mdouble_ __y
));
310 /* Return X times (2 to the Nth power). */
311 __MATHCALL (scalbn
,, (_Mdouble_ __x
, int __n
));
314 /* Return the binary exponent of X, which must be nonzero. */
315 __MATHDECL (int,ilogb
,, (_Mdouble_ __x
));
318 #if __GLIBC_USE (IEC_60559_BFP_EXT)
319 /* Like ilogb, but returning long int. */
320 __MATHDECL (long int, llogb
,, (_Mdouble_ __x
));
324 /* Return X times (2 to the Nth power). */
325 __MATHCALL (scalbln
,, (_Mdouble_ __x
, long int __n
));
327 /* Round X to integral value in floating-point format using current
328 rounding direction, but do not raise inexact exception. */
329 __MATHCALL (nearbyint
,, (_Mdouble_ __x
));
331 /* Round X to nearest integral value, rounding halfway cases away from
333 __MATHCALLX (round
,, (_Mdouble_ __x
), (__const__
));
335 /* Round X to the integral value in floating-point format nearest but
336 not larger in magnitude. */
337 __MATHCALLX (trunc
,, (_Mdouble_ __x
), (__const__
));
339 /* Compute remainder of X and Y and put in *QUO a value with sign of x/y
340 and magnitude congruent `mod 2^n' to the magnitude of the integral
341 quotient x/y, with n >= 3. */
342 __MATHCALL (remquo
,, (_Mdouble_ __x
, _Mdouble_ __y
, int *__quo
));
345 /* Conversion functions. */
347 /* Round X to nearest integral value according to current rounding
349 __MATHDECL (long int,lrint
,, (_Mdouble_ __x
));
351 __MATHDECL (long long int,llrint
,, (_Mdouble_ __x
));
353 /* Round X to nearest integral value, rounding halfway cases away from
355 __MATHDECL (long int,lround
,, (_Mdouble_ __x
));
357 __MATHDECL (long long int,llround
,, (_Mdouble_ __x
));
360 /* Return positive difference between X and Y. */
361 __MATHCALL (fdim
,, (_Mdouble_ __x
, _Mdouble_ __y
));
363 /* Return maximum numeric value from X and Y. */
364 __MATHCALLX (fmax
,, (_Mdouble_ __x
, _Mdouble_ __y
), (__const__
));
366 /* Return minimum numeric value from X and Y. */
367 __MATHCALLX (fmin
,, (_Mdouble_ __x
, _Mdouble_ __y
), (__const__
));
370 /* Classify given number. */
371 __MATHDECL_1 (int, __fpclassify
,, (_Mdouble_ __value
))
372 __attribute__ ((__const__
));
374 /* Test for negative number. */
375 __MATHDECL_1 (int, __signbit
,, (_Mdouble_ __value
))
376 __attribute__ ((__const__
));
379 /* Multiply-add function computed as a ternary operation. */
380 __MATHCALL (fma
,, (_Mdouble_ __x
, _Mdouble_ __y
, _Mdouble_ __z
));
381 #endif /* Use ISO C99. */
383 #if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
387 #if __GLIBC_USE (IEC_60559_BFP_EXT)
388 /* Round X to nearest integer value, rounding halfway cases to even. */
389 __MATHCALLX (roundeven
,, (_Mdouble_ __x
), (__const__
));
391 /* Round X to nearest signed integer value, not raising inexact, with
392 control of rounding direction and width of result. */
393 __MATHDECL (__intmax_t
, fromfp
,, (_Mdouble_ __x
, int __round
,
394 unsigned int __width
));
396 /* Round X to nearest unsigned integer value, not raising inexact,
397 with control of rounding direction and width of result. */
398 __MATHDECL (__uintmax_t
, ufromfp
,, (_Mdouble_ __x
, int __round
,
399 unsigned int __width
));
401 /* Round X to nearest signed integer value, raising inexact for
402 non-integers, with control of rounding direction and width of
404 __MATHDECL (__intmax_t
, fromfpx
,, (_Mdouble_ __x
, int __round
,
405 unsigned int __width
));
407 /* Round X to nearest unsigned integer value, raising inexact for
408 non-integers, with control of rounding direction and width of
410 __MATHDECL (__uintmax_t
, ufromfpx
,, (_Mdouble_ __x
, int __round
,
411 unsigned int __width
));
413 /* Return value with maximum magnitude. */
414 __MATHCALLX (fmaxmag
,, (_Mdouble_ __x
, _Mdouble_ __y
), (__const__
));
416 /* Return value with minimum magnitude. */
417 __MATHCALLX (fminmag
,, (_Mdouble_ __x
, _Mdouble_ __y
), (__const__
));
420 __MATHDECL_1 (int, __iseqsig
,, (_Mdouble_ __x
, _Mdouble_ __y
));
422 /* Test for signaling NaN. */
423 __MATHDECL_1 (int, __issignaling
,, (_Mdouble_ __value
))
424 __attribute__ ((__const__
));
426 /* Total order operation. */
427 __MATHDECL_1 (int, totalorder
,, (_Mdouble_ __x
, _Mdouble_ __y
))
428 __attribute__ ((__const__
));
430 /* Total order operation on absolute values. */
431 __MATHDECL_1 (int, totalordermag
,, (_Mdouble_ __x
, _Mdouble_ __y
))
432 __attribute__ ((__const__
));
434 /* Canonicalize floating-point representation. */
435 __MATHDECL_1 (int, canonicalize
,, (_Mdouble_
*__cx
, const _Mdouble_
*__x
));
437 /* Get NaN payload. */
438 __MATHCALL (getpayload
,, (const _Mdouble_
*__x
));
440 /* Set quiet NaN payload. */
441 __MATHDECL_1 (int, setpayload
,, (_Mdouble_
*__x
, _Mdouble_ __payload
));
443 /* Set signaling NaN payload. */
444 __MATHDECL_1 (int, setpayloadsig
,, (_Mdouble_
*__x
, _Mdouble_ __payload
));
447 #if defined __USE_MISC || (defined __USE_XOPEN_EXTENDED \
448 && __MATH_DECLARING_DOUBLE \
449 && !defined __USE_XOPEN2K8)
450 /* Return X times (2 to the Nth power). */
451 __MATHCALL (scalb
,, (_Mdouble_ __x
, _Mdouble_ __n
));